ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Upper & Lower case problem in VBA (https://www.excelbanter.com/excel-discussion-misc-queries/12407-upper-lower-case-problem-vba.html)

Rob

Upper & Lower case problem in VBA
 
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




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

In article , "Rob" <NA wrote:

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


Rob

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

Rob

"JE McGimpsey" wrote in message
...
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

In article , "Rob" <NA wrote:

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





All times are GMT +1. The time now is 09:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com