ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sheetname search question (https://www.excelbanter.com/excel-programming/339407-sheetname-search-question.html)

RAP

sheetname search question
 
Hello,
Trying to find a way, using VBA, to locate and activate a sheet by name,
using a wildcard search.
The workbooks I need to open are not consistently organized and sheet names
are different, but all contain "Jan" thru "Dec" in some form.
Ex: Platform1 (JAN),Platform2 JAN, Platform3Jan, etc...

Much appreciated. - Randy


JE McGimpsey

sheetname search question
 
One way:

Public Sub ActivateJan()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If UCase(ws.Name) Like "*JAN*" Then
ws.Activate
Exit Sub
End If
Next ws
MsgBox "No JANs found"
End Sub


In article ,
RAP wrote:

Hello,
Trying to find a way, using VBA, to locate and activate a sheet by name,
using a wildcard search.
The workbooks I need to open are not consistently organized and sheet names
are different, but all contain "Jan" thru "Dec" in some form.
Ex: Platform1 (JAN),Platform2 JAN, Platform3Jan, etc...

Much appreciated. - Randy


RAP

sheetname search question
 
Works just fine. Thank you! Apparently, I just have a thing with syntax. I
was close, but you nailed it. Thanks again,
Randy

"JE McGimpsey" wrote:

One way:

Public Sub ActivateJan()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If UCase(ws.Name) Like "*JAN*" Then
ws.Activate
Exit Sub
End If
Next ws
MsgBox "No JANs found"
End Sub


In article ,
RAP wrote:

Hello,
Trying to find a way, using VBA, to locate and activate a sheet by name,
using a wildcard search.
The workbooks I need to open are not consistently organized and sheet names
are different, but all contain "Jan" thru "Dec" in some form.
Ex: Platform1 (JAN),Platform2 JAN, Platform3Jan, etc...

Much appreciated. - Randy




All times are GMT +1. The time now is 01:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com