VBA issue help? lower case vs Upper Case

FGaxha

Board Regular
Joined
Jan 10, 2023
Messages
221
Office Version
  1. 365
Platform
  1. Windows
I have a macro ruining on range A2:V7500, looking for two conditional Names" "OES" and "James" and copy data to new tab

If names "OES" or "James" are UPPER case letter, then does not count. Any suggestions please.
--------------
Sub test3()
Dim outarr()
inarr = Range("A1:V7500")
ReDim outarr(1 To 7500, 1 To 22)
indi = 1
For i = 2 To 7500
If inarr(i, 10) = "OES" And inarr(i, 20) = "James" And inarr(i, 22) <= 12 Then
' copy row
For j = 1 To 22
outarr(indi, j) = inarr(i, j)
Next j
indi = indi + 1
End If
Next i
Worksheets.Add
ActiveSheet.Name = "James"
If indi > 1 Then
Range(Cells(1, 1), Cells(indi - 1, 22)) = outarr
End If
End Sub
------
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try:
VBA Code:
If UCase(inarr(i, 10)) = "OES" And UCase(inarr(i, 20)) = "JAMES" And inarr(i, 22) <= 12 Then
 
Upvote 0
Solution
Well,
Im looking for either Upper case , Lower Case and combine upper and lower case. Input data are entered by others so sometimes names can be typed differently?

Thanks again.
 
Upvote 0
Well,
Im looking for either Upper case , Lower Case and combine upper and lower case. Input data are entered by others so sometimes names can be typed differently?

Thanks again.
Yes, my code will do that. Did you try it?

The logic is that VBA is converting everything to Upper Case for purposes of testing it.
So:
"oes" becomes "OES"
"Oes" becomes "OES"
"OES" stays "OES"
etc.

By making everything upper case, we can then compare it to "OES".
So we are standardizing it all for the sake of the comparsion to remove the different ways it may be entered.
 
Upvote 1
Yes, my code will do that. Did you try it?

The logic is that VBA is converting everything to Upper Case for purposes of testing it.
So:
"oes" becomes "OES"
"Oes" becomes "OES"
"OES" stays "OES"
etc.

By making everything upper case, we can then compare it to "OES".
So we are standardizing it all for the sake of the comparsion to remove the different ways it may be entered.
Can I create 5 macros by just changing the name. From "James" to XXX, YYY, ZZZ, WWW.? on same workbook??
I can copy the same vba and add as new with new name?
your thoughts please??
 
Upvote 0
Can I create 5 macros by just changing the name. From "James" to XXX, YYY, ZZZ, WWW.? on same workbook??
I can copy the same vba and add as new with new name?
your thoughts please??
I don't understand what you are asking here, or how it relates to the original question.
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,660
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top