Case Insensitive Search

kod2th3e

Board Regular
Joined
Apr 2, 2008
Messages
87
I have the code below that takes the user input from a text box "strtraveler" (a traveler number typicall looks like 12345p678and finds what the user inputs on the sheet and moves it to another area then deletes it from its previous area. This is case sensitive and I don't want it to be, sometimes what is on the sheet will have an upper case "P" or lower case "p" and if what the user types in doesn't fully mactch it won't move/clear out the traveler. Is there a way for the code to recognize the string as being the same whether the "p" in the middle is upper or lower case and execute?

Sub assignjobtomachine2()
Application.ScreenUpdating = False
Dim rnum As Integer
rnum = 22

Dim strtraveler As String
strtraveler = InputBox("Please enter the traveler number " & _
"you would like to assign to the machine.", "Assign:")

If strtraveler <> "" Then
Sheets("Machine 2 Schedule").Unprotect "gxs"


'Clears out job from "Not Yet Assigned To Machine" schedule and places
'it on Machine #2 - (Aerospace Jobs) schedule
Do Until rnum = 300
If Cells(rnum, 4) = strtraveler Then
If Cells(16, 3).Value > "" Then
MsgBox "Only 4 jobs can be assigned to a machine at once.", vbExclamation, "Error.."
Exit Sub
End If
Cells(rnum, 3).Copy
Call assignjobnumber
Cells(rnum, 4).Copy
Call assigntravelernumber
Cells(rnum, 5).Copy
Call assignassemblynumber
Cells(rnum, 6).Copy
Call assignquantity
Cells(rnum, 7).Copy
Call assigntimein
Cells(rnum, 8).Copy
Call assignduedate
Range((Cells(rnum, 2)), (Cells(rnum, 8))).Select
Selection.Delete shift:=xlUp
Call priority
Call formatmachinejobs
ElseIf Cells(rnum, 4) <> strtraveler Then
rnum = rnum + 1
End If
Loop
End If
'call lockdown
ThisWorkbook.Save
End Sub


Any help would be great, thanks.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Will this work???

putting your search tring and cell to uppercase will compare them both in the same format or you can use lowercase too.

your code....

'adding a ucase to cell and strtraveler will compare them both in uppercase
If UCase(Cells(rnum, 4)) = UCase(strtraveler) Then

your code....

'adding a ucase to cell and strtraveler will compare them both in uppercase
ElseIf UCase(Cells(rnum, 4)) <> UCase(strtraveler) Then

your code....
 
Upvote 0

Forum statistics

Threads
1,224,225
Messages
6,177,273
Members
452,765
Latest member
Erka Gizli

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