LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Dynamically setting Dimensions in a VBA loop

Hey all.

Having some issues with this, and wanted to see if you have any ideas.

Essentially what I am doing is looping through 9 sheets and excecuting some
code to create pivot tables on each sheet.

For my code to work properly I need a few dimensions assigned, 'TbName' and
'RegionSelect'

What I have now is this just reiterated 9 times, with tb name being 9
different names and 9 different sheets being selected

Sheets("Sheet").Select
TbName = "Name of region"
RegionSelect = ActiveSheet.Name
My_Macro


So now I have come up with this code below:

Public TbName As String
Public RegionSelect As String
Dim wSht As Integer

Sheets(1).Select
wSht = ActiveSheet.Index
Do While wSht < 10
If wSht = 1 Then
Sheets(wSht).Select
Else
End If

Sheets(wSht).Select
TbName = ActiveSheet.Name
'Code that does stuff will go here
wSht = wSht + 1

Loop


What I need is a way to assign 'RegionSelect' with the proper region for
each sheet
The only way I can think of doing this is to create 9 If statements like:

If activesheet.name = "sheet 1" Then
Regionselect = "Region1"
End if

Is there a better way to do this?

 
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
Setting Multiple Variables with a loop jlclyde Excel Discussion (Misc queries) 6 November 11th 09 09:40 PM
Dynamically setting worksheet tab colors John Excel Worksheet Functions 4 January 29th 09 06:55 PM
Setting Range Dynamically DJS Excel Discussion (Misc queries) 5 December 7th 06 09:51 PM
TextToColumns delimiter setting ignored w/in VB loop Amy[_8_] Excel Programming 0 February 15th 05 07:15 PM
Dynamically setting Print Area Kevin Excel Programming 3 September 24th 04 08:11 PM


All times are GMT +1. The time now is 02:44 PM.

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

About Us

"It's about Microsoft Excel"