Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link variable data from one worksheet to another worksheet? T MAT New Users to Excel 3 November 27th 07 06:46 AM
Variable worksheet name (tab) linked to cell in same worksheet azbob Excel Worksheet Functions 6 January 9th 07 06:27 PM
Looking up a variable in one worksheet and copying information from another column to another worksheet?? Brad Torken Excel Discussion (Misc queries) 2 December 10th 06 06:02 AM
Variable worksheet name Chris Excel Worksheet Functions 1 April 24th 06 05:35 PM
Assigning worksheet to worksheet variable PO Excel Programming 3 February 10th 04 02:22 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"