Macro basics
In , Dave Peterson
spake thusly:
It sounds like you're in business.
Good luck with the tweaks.
I've been tweaking away. Uncovered and fixed a couple of bugs.
Now I'm trying to do more with the loop that uses an array of
worksheet names.
My main question for this part of the thread is: can I, in
VBA, set variable using dynamic names?
To explain, I'll show where I'm at now, with stuff before and after
left off:
-----------------
Sub RGUpdate()
'stuff deleted
Set csvRG = Worksheets("2006 Realized - CSV Data")
Set csvUG = Worksheets("Current - CSV Data")
'stuff deleted
Dim iCtr As Long
Dim wsNames As Variant
wsNames = Array(csvRG, csvUG)
For iCtr = LBound(wsNames) To UBound(wsNames)
With wsNames(iCtr)
.Activate 'this turns out to be necessary
.Visible = True
.Unprotect
Range("A1").Select 'just a "focus" thing
'still wish I didn't have to hit Enter to accept this query:
.QueryTables(1).Refresh BackgroundQuery:=False
.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True
'code I want to add with dynamic var naming:
'== csvRGLastR = .Cells(.Rows.Count, "A").End(xlUp).Row
'^^^^^ {OR}
'== csvUGLastR = .Cells(.Rows.Count, "A").End(xlUp).Row
'^^^^^ Those are strings, but based on the nicknames for the sheets!
.Visible = False
End With
Next iCtr
'stuff deleted
End Sub
-----------------
Okay, is anything like that possible?
Thanks,
-dman-
|