Need help with syntax
You can iterate the Columns collection and not specifically number the
columns. I would think this would work...
Dim ColumnNum As Range
For Each ColumnNum In Rows(7).Columns
If Cells(7, ColumnNum.Column).Value = VS Then
Cells(RowNum, ColumnNum).Locked = True
End If
Next
Rick
"Roger Govier" <roger@technology4unospamdotcodotuk wrote in message
...
Hi James
What you have posted will not work. Column number does need to be set and
incremented.
You could use something like
Sub lockcells()
Dim i As Long, j As Long
j = 7 ' row number
For i = 1 To 26 ' number of columns
If Cells(j, i) = VS Then
Cells(j, i).Locked = False
End If
Next
End Sub
--
Regards
Roger Govier
"James" wrote in message
...
Hi everyone. Ive seen stuff like this but im not sure how to implement it
correctly. I need to look in row 7 & cycle through each column (with
text).
Something like:
'VS previously set
'RowNum previously set
For each ColumnNum in row 7
if cell(7, ColumnNum).Value = VS then
Cells(RowNum, ColumnNum).Locked = True
End if
Next
Ive seen something like this before and i understand what is goin on but
usually the "ColumnNum" part in the for statement is never declared or
set to
anything...why is this? Thanks for the help!
|