View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] mars1968@gmail.com is offline
external usenet poster
 
Posts: 2
Default using variables in codenames

I am trying to write a code that allow a variable in the code name of a
worksheet.

Example
3 worksheets in the workbook with the following names:
worksheet 1 codename = page1
worksheet 2 codename = page2
worksheet 3 codename = page3

I want to write a code that works like the following:

for x = 1 to 3
worksheets(page x .Name).activate ' or other sheet
comand using codename
range ("a1")= "1"
next x

instead of writing the following
worksheets(page1 .Name).activate
range ("a1")= "1"
worksheets(page2 .Name).activate
range ("a1")= "1"
worksheets(page3 .Name).activate
range ("a1")= "1"

suggestions?