Simplify macro

Sumeluar

Board Regular
Joined
Jun 21, 2006
Messages
241
Good day to all gurus out there, I have a find code and I want it to skip the words like search, category, Go to, etc.


Can this be simplified?
Code:
If myText = "Search" Then GoTo Litz
If myText = "search" Then GoTo Litz
If myText = "category" Then GoTo Litz
If myText = "Category" Then GoTo Litz
If myText = "Go" Then GoTo Litz
If myText = "go" Then GoTo Litz
If myText = "Go to" Then GoTo Litz
If myText = "go to" Then GoTo Litz

Regards!

Sumeluar
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
If UCase(mytext) = "SEARCH" Or UCase(mytext) = "CATEGORY" Or UCase(mytext) = "GO" Or UCase(mytext) = "GOTO" Then GoTo Litz
 

QuietRiot

Well-known Member
Joined
May 18, 2007
Messages
1,077
Code:
Dim myarray, j As Integer, txt As String, check As String
myarray = Array("Search", "search", "category", "Category", "Go", "go", "Go to", "go to")
    For j = LBound(myarray) To UBound(myarray)
        If txt = myarray(j) Then check = "Yes"
    Next j
    If check = "Yes" Then GoTo Litz
 

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Code:
If UCase(myText) = "SEARCH" or If UCase(myText) = "CATEGORY" or If UCase(myText) = "GO TO" then GoTo Litz

But you probably want to avoid using GoTo as well. Perhaps reviewing the rest of your code might be beneficial.

Hope that helps! :)
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Maybe something like this
Code:
X = Array("SEARCH","CATEGORY","GO","GOTO") 
On Error Resume Next
Y = ""
Y = WorksheetFunction.Match(Ucase(mytext),X)
If Y <> "" Then Goto Litz
 

Watch MrExcel Video

Forum statistics

Threads
1,122,551
Messages
5,596,797
Members
414,103
Latest member
imamalidadashzada

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
Top