Sub to freeze cols up to extent of data in col Q

M

Max

Cols R and U contain formulas till row 200. I need a sub to freeze cols R and
U from row 4 to the last row of data in col Q (taken from bottom up). Col Q
contains only data, no formulas. Thanks
 
J

Jacob Skaria

Max, try the below in activesheet

Sub Macro()
Dim lngRow As Long


lngRow = Cells(Rows.Count, "Q").End(xlUp).Row
Cells.Locked = False
Range("Q4:R" & lngRow).Locked = True
ActiveSheet.Protect Password:="password"
End Sub
 
M

Max

Sorry, what I meant by "freeze" was to convert the formulas in cols R and U
to values (copy > paste special as values). What should be changed in the sub
to do that? Thanks
 
M

Max

Thanks, but I'm not sure how to adapt those lines to suit the desired
"freeze" extent, ie only from row 4 down to the last row of data in col Q,
not the entire col. Grateful if you could take a moment to piece it together
 
J

Jacob Skaria

OK. Try the below

Sub Macro()
Dim lngRow As Long

lngRow = Cells(Rows.Count, "Q").End(xlUp).Row

Range("R4:R" & lngRow) = Range("R4:R" & lngRow).Value
Range("U4:U" & lngRow) = Range("U4:U" & lngRow).Value

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top