If the functions in the freely downloadable file at
http://home.pacbel.net/beban are available to your workbook
Dim wsArr() As String
ReDim wsArr(0 To 0)
Assign Array("Value1", "Value2", "Value3", "Value4", "Value5", _
"Value6", "Value7", "Value8"), wsArr
Alan Beban
Geoff wrote:
> 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