![]() |
Variable VBA Worksheet Name
Hi,
Can anyone tell me how to generate a variable VBA worksheet name so I can search through the set up sheets. Basically the VBA names of my sheets are S1 to S10 allowing me to use the S1.Activate etc... How can I set up the Sheet name to be something like: wrksheetnum = (loop through worksheet numbers) wrksheetname = "S" & wrksheetnum wrksheetname.activate loop etc... How do I get the wrksheetname bit to work? Thanks David |
Variable VBA Worksheet Name
Dim wrksheetnum as Long
Dim wrksheetname as String wrksheetnum = (loop through worksheet numbers) wrksheetname = "S" & wrksheetnum Worksheets(wrksheetname).activate -- Regards, Tom Ogilvy "Dave" wrote in message oups.com... Hi, Can anyone tell me how to generate a variable VBA worksheet name so I can search through the set up sheets. Basically the VBA names of my sheets are S1 to S10 allowing me to use the S1.Activate etc... How can I set up the Sheet name to be something like: wrksheetnum = (loop through worksheet numbers) wrksheetname = "S" & wrksheetnum wrksheetname.activate loop etc... How do I get the wrksheetname bit to work? Thanks David |
Variable VBA Worksheet Name
Hi Dave,
Try something like: '========= Public Sub Tester() Dim SH As Worksheet For Each SH In ActiveWorkbook.Worksheets 'do something, e.g.: MsgBox SH.Name Next SH End Sub '<<========= BTW, it is rarely necessary to select a sheet; mot operations can be performed using the SH object variable. --- Regards, Norman "Dave" wrote in message oups.com... Hi, Can anyone tell me how to generate a variable VBA worksheet name so I can search through the set up sheets. Basically the VBA names of my sheets are S1 to S10 allowing me to use the S1.Activate etc... How can I set up the Sheet name to be something like: wrksheetnum = (loop through worksheet numbers) wrksheetname = "S" & wrksheetnum wrksheetname.activate loop etc... How do I get the wrksheetname bit to work? Thanks David |
All times are GMT +1. The time now is 12:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com