How to ignore capital letters in a comparison structure

Asked

Viewed 44 times

0

I am trying to make a comparison in a spreadsheet and manage to define the range and tbm the conditional formula, but I am incurring a basic error that are the uppercase letters... for cells that contain uppercase letter my conditional formula does not work.
I’ve tried the .lower() to ignore the capital but not working...

Dim x As Integer
x = ActiveSheet.UsedRange.Rows.Count
y = 2
z = 18
w = 17
Do While y <= x
If ActiveSheet.Cells(y, z).Value = "laranja" Or ActiveSheet.Cells(y, z).Value = "banana" Then
ActiveSheet.Cells(y, w).Value = "frutas"
End If
y = y + 1
Loop
End Sub

1 answer

1

Convert everything to lower or upper case before comparing, for example:

If LCase(ActiveSheet.Cells(y, z).Value) = LCase("laranja") ....

Another way and add to the beginning of the code the Statement Option Compare

Option Compare Text

This will make all comparisons ignore the case.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.