Help with String Searching in Macro

  • Thread starter Thread starter silks
  • Start date Start date
S

silks

Hiya,

I am trying to activate a worksheet based upon the first 2 character
of its name.

The question is, how do I search the name of a worksheet?

I want something along the lines of

Range("A1").Select
If Selection = 01 then
Sheets("01Jan").Select
Else
If Selection = 02 then
Sheets("02Jan").Select
<etc>
End if
End if
<etc>

As you can probably see from this i'm new and rubbish!

Cheer
 
Something like this might work for you:

Sub SheetSelect()

Sheets(Range("A1") & "Jan").Activate

End Sub

This takes the value of A1 (which must be text formatted) and concatenates
it with the "Jan" string to form the sheet name 01Jan.

HTH

--
Michael J. Malinsky
Pittsburgh, PA

"I was gratified to be able to answer promptly,
and I did. I said I didn't know." -- Mark Twain
 
Sub WorksheetFindNames()
For i = 1 To Application.Worksheets.Count
MsgBox Worksheets(i).Name
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top