![]() |
Select some sheets automatically
I am trying to write a routine to select all sheets that have (1) at the end
of the sheet name. This is what I have so far, can anyone help? Thanks Sub Select_1() Dim SelectedSheets As String Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets If ws.Name Like "*(1)" Then SelectedSheets = SelectedSheets + ", " + ws.Name End If Next ws Sheets(SelectedSheets).Select End Sub |
Select some sheets automatically
Hi M,
Try: '============= Public Sub Tester() Dim ws As Worksheet Dim blReplace As Boolean blReplace = True For Each ws In ActiveWorkbook.Worksheets If ws.Name Like "*(1)" Then ws.Select blReplace blReplace = False End If Next ws End Sub '<<============= --- Regards, Norman "mcphc" wrote in message ... I am trying to write a routine to select all sheets that have (1) at the end of the sheet name. This is what I have so far, can anyone help? Thanks Sub Select_1() Dim SelectedSheets As String Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets If ws.Name Like "*(1)" Then SelectedSheets = SelectedSheets + ", " + ws.Name End If Next ws Sheets(SelectedSheets).Select End Sub |
Select some sheets automatically
Thanks that works great!
"Norman Jones" wrote: Hi M, Try: '============= Public Sub Tester() Dim ws As Worksheet Dim blReplace As Boolean blReplace = True For Each ws In ActiveWorkbook.Worksheets If ws.Name Like "*(1)" Then ws.Select blReplace blReplace = False End If Next ws End Sub '<<============= --- Regards, Norman "mcphc" wrote in message ... I am trying to write a routine to select all sheets that have (1) at the end of the sheet name. This is what I have so far, can anyone help? Thanks Sub Select_1() Dim SelectedSheets As String Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets If ws.Name Like "*(1)" Then SelectedSheets = SelectedSheets + ", " + ws.Name End If Next ws Sheets(SelectedSheets).Select End Sub |
All times are GMT +1. The time now is 10:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com