View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Need help with syntax

try this
Sub valuesinrow()
mr = 7
For i = 1 To Cells(mr, Columns.Count).End(xlToLeft).Column
If Cells(mr, i)) = VS Then Cells(mr, i).Locked = True
'If ucase(Cells(mr, i)) = "VS" Then Cells(mr, i).Locked = True
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"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!