Upper & Lower case problem in VBA

R

Rob

I have the following formula to lock cells if the value in col I = X but
sometimes it may be a lowercase x. How can this be adapted to lock the
cells no matter if the x is upper or lower case?

For Each cell In ActiveSheet.Range("I13:I1000")
With cell
.Offset(0, -7).Resize(1, 8).Locked = .Value = "X"
End With
Next cell
 
J

JE McGimpsey

one way:

For Each cell In ActiveSheet.Range("I13:I1000")
With cell
.Offset(0, -7).Resize(1, 8).Locked = UCase(.Text) = "X"
End With
Next cell
 
R

Rob

Thanks JE,
Works great and such a minor change too as I was expecting some complex
code.

Rob
 

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