nnicolazzi
New Member
- Joined
- Jun 9, 2017
- Messages
- 5
Greetings! Long time reader, first time poster. I'm sure there is an answer to this question somewhere but I have spent hours reading trying to find a solution and still cannot find it. Any help will be greatly appreciated! Thanks!
Goal: Use a For Loop to loop through an Array of Sheet Names and do some method.
Problem: The problem that I am having is that when I run the macro it only updates the sheet that is already selected in the workbook. It also says that my variable is "Empty" even after I set the variable to equal the array.
Example: For illustration I've simplified my project to create and array of specific sheets in my workbook and set the value of cell A1 = 1.
The code is below.
Sub Macro2()
Dim MyArray As Variant
Dim i As Variant
Set MyArray = Sheets(Array("Room 1", "Room 2", "Room 3"))
For Each i In MyArray
ActiveSheet.Cells(1, 1) = 1
Next i
End Sub
Thanks so much again! any help/articles/links/ will be greatly appreciated
Goal: Use a For Loop to loop through an Array of Sheet Names and do some method.
Problem: The problem that I am having is that when I run the macro it only updates the sheet that is already selected in the workbook. It also says that my variable is "Empty" even after I set the variable to equal the array.
Example: For illustration I've simplified my project to create and array of specific sheets in my workbook and set the value of cell A1 = 1.
The code is below.
Sub Macro2()
Dim MyArray As Variant
Dim i As Variant
Set MyArray = Sheets(Array("Room 1", "Room 2", "Room 3"))
For Each i In MyArray
ActiveSheet.Cells(1, 1) = 1
Next i
End Sub
Thanks so much again! any help/articles/links/ will be greatly appreciated