Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd like to do something like the following
For i = 1 to 10 Set aws = "Test" & i 'Test1-test10 are worksheet code names 'perform actions on aws next i How do I do this? Thanks, Barb Reinhardt |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sounds like you're wanting to loop through sheets Test1 through Test 10.
Post back if that's not it. As an example, the following code will perform an action on Sheets Test1-Test10 by placing "Hello, World" in cell A1. Dim sht as Worksheet Dim i as integer For i=1 to 10 set sht = Worksheets("Test" & i) sht.Range("A1").Value = "Hello, World" Next i set sht=Nothing -- Hope that helps. Vergel Adriano "Barb Reinhardt" wrote: I'd like to do something like the following For i = 1 to 10 Set aws = "Test" & i 'Test1-test10 are worksheet code names 'perform actions on aws next i How do I do this? Thanks, Barb Reinhardt |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is a solution that I have used. It is a little different from what you
asked but it works... Sub test() Dim wks As Worksheet For Each wks In Worksheets If Left(wks.CodeName, 4) = "Test" Then MsgBox wks.CodeName Next wks End Sub -- HTH... Jim Thomlinson "Barb Reinhardt" wrote: I'd like to do something like the following For i = 1 to 10 Set aws = "Test" & i 'Test1-test10 are worksheet code names 'perform actions on aws next i How do I do this? Thanks, Barb Reinhardt |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. Why didn't I think of that?
"Vergel Adriano" wrote: Sounds like you're wanting to loop through sheets Test1 through Test 10. Post back if that's not it. As an example, the following code will perform an action on Sheets Test1-Test10 by placing "Hello, World" in cell A1. Dim sht as Worksheet Dim i as integer For i=1 to 10 set sht = Worksheets("Test" & i) sht.Range("A1").Value = "Hello, World" Next i set sht=Nothing -- Hope that helps. Vergel Adriano "Barb Reinhardt" wrote: I'd like to do something like the following For i = 1 to 10 Set aws = "Test" & i 'Test1-test10 are worksheet code names 'perform actions on aws next i How do I do this? Thanks, Barb Reinhardt |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually, that's more like what I was looking for. Thanks.
"Jim Thomlinson" wrote: Here is a solution that I have used. It is a little different from what you asked but it works... Sub test() Dim wks As Worksheet For Each wks In Worksheets If Left(wks.CodeName, 4) = "Test" Then MsgBox wks.CodeName Next wks End Sub -- HTH... Jim Thomlinson "Barb Reinhardt" wrote: I'd like to do something like the following For i = 1 to 10 Set aws = "Test" & i 'Test1-test10 are worksheet code names 'perform actions on aws next i How do I do this? Thanks, Barb Reinhardt |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't think that works for the sheets code name.
-- HTH... Jim Thomlinson "Vergel Adriano" wrote: Sounds like you're wanting to loop through sheets Test1 through Test 10. Post back if that's not it. As an example, the following code will perform an action on Sheets Test1-Test10 by placing "Hello, World" in cell A1. Dim sht as Worksheet Dim i as integer For i=1 to 10 set sht = Worksheets("Test" & i) sht.Range("A1").Value = "Hello, World" Next i set sht=Nothing -- Hope that helps. Vergel Adriano "Barb Reinhardt" wrote: I'd like to do something like the following For i = 1 to 10 Set aws = "Test" & i 'Test1-test10 are worksheet code names 'perform actions on aws next i How do I do this? Thanks, Barb Reinhardt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Dynamically Reference Offline Workbook/worksheet | Excel Discussion (Misc queries) | |||
How to dynamically add/change Reference? | Excel Programming | |||
Cell Reference is Worksheet Name in VB Code | Excel Programming | |||
Cell Reference is Worksheet Name in VB Code | Excel Programming | |||
Altering code to reference the worksheet before the active worksheet | Excel Programming |