G
Geoff
I would like to run the same code over a number of worksheets, and to this
end I've declared a static array as follows:
Dim tmpBk As Workbook
Dim wsArr(1 To 8) As String
Dim wsName As String
Dim tmpWs As Worksheet
Dim tmpRng As Range
Dim dataName As String
Dim firstDay As Date
firstDay = DateSerial(yr, mth, 1)
dataName = DATAPATH & yr & "hi\" & Format(firstDay, "mmyy") & "hi.xls"
Workbooks.Open dataName, 0, True
wsArr = Array("Value1", "Value2", "Value3", "Value4", _
"Value5", "Value6", "Value7", "Value8")
Set tmpBk = Workbooks.Open(HCMCPATH & "something.xls", 0)
For Each wsName In wsArr
Set tmpWs = tmpBk.Worksheets(wsName)
[snip]
Next wsName
When I try to compile this I get the error "Can't assign to array". I know I
could go through one by one and assign the values by saying
wsArr(1) = Value1
for instance but I'd like to get them all done at once.
Any suggestions?
TIA
end I've declared a static array as follows:
Dim tmpBk As Workbook
Dim wsArr(1 To 8) As String
Dim wsName As String
Dim tmpWs As Worksheet
Dim tmpRng As Range
Dim dataName As String
Dim firstDay As Date
firstDay = DateSerial(yr, mth, 1)
dataName = DATAPATH & yr & "hi\" & Format(firstDay, "mmyy") & "hi.xls"
Workbooks.Open dataName, 0, True
wsArr = Array("Value1", "Value2", "Value3", "Value4", _
"Value5", "Value6", "Value7", "Value8")
Set tmpBk = Workbooks.Open(HCMCPATH & "something.xls", 0)
For Each wsName In wsArr
Set tmpWs = tmpBk.Worksheets(wsName)
[snip]
Next wsName
When I try to compile this I get the error "Can't assign to array". I know I
could go through one by one and assign the values by saying
wsArr(1) = Value1
for instance but I'd like to get them all done at once.
Any suggestions?
TIA