runtime error 9 -- subscript out of range
dave, could it be a memory issue?
--
Gary
"Dave Peterson" wrote in message
...
That error means that whatever you referred in your collections (worksheets()
or
workbooks()) or your arrays (vaworkforce() or vaog() or ...) doesn't exist.
But I couldn't even guess what line caused the error.
But if it's working 2425 times, I'm guessing that it's one of your arrays.
Milind Keer wrote:
Hi
I am getting runtime error 9 - subscript out of range for following code...
This code is basically pasting values to 'UK - SI - CHT' sheet from an array.
the ubound value of the array is 55000, it is successfully pasting 2425
records but then giving 'runtime error 9 -- subscript out of range'
Wat could be the reason??? Please help...
vUKOnlyXLReport = "SI CtS May-08 UK Only - detail plus graphs CCI%.xls"
Workbooks.Open (vGlobalReportPath & vUKOnlyXLReport)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Activate
vMatch = "Systems Integration & TechnologySystems IntegrationUK,
IrelandUnited KingdomCommunications & High Tech"
Dim iR As Long
Dim iRow As Long
iR = 2
For iRow = 2 To UBound(vaGrowthPlatform)
If vMatch = vaGrowthPlatform(iRow) & vaServiceGroup(iRow) &
vaGeography(iRow) & vaGeoCity(iRow) & vaOG(iRow) Then
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("A"
& iR).Value = vaWorkforce(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("B"
& iR).Value = vaOG(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("C"
& iR).Value = vaGeography(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("D"
& iR).Value = vaGeoCity(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("F"
& iR).Value = vaSumOfhours_total_ytd(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("G"
& iR).Value = vagdn_locale_cd(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("H"
& iR).Value = vamstr_client_name(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("I"
& iR).Value = vamstr_contract_nbr(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("J"
& iR).Value = vamstr_contract_name(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("K"
& iR).Value = vawbselement_cd(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("L"
& iR).Value = vawbselement_desc(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("T"
& iR).Value = vaSumOfcosts_payroll_ytd(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("U"
& iR).Value = vaSumOfcosts_loads_ytd(iRow)
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("V"
& iR).Value = vaSumOfcosts_seat_charges_ytd(iRow)
SumofYTDLoadedcosts = (vaSumOfcosts_payroll_ytd(iRow) +
vaSumOfcosts_loads_ytd(iRow) + vaSumOfcosts_loads_ytd(iRow))
If vaSumOfhours_total_ytd(iRow) < 0 Then
CtS = SumofYTDLoadedcosts / vaSumOfhours_total_ytd(iRow)
Else
CtS = ""
End If
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("E"
& iR).Value = SumofYTDLoadedcosts
Workbooks(vUKOnlyXLReport).Worksheets("UK - SI - CHT").Range("M"
& iR).Value = CtS
iR = iR + 1
End If
Next iRow
Workbooks(vUKOnlyXLReport).Close SaveChanges:=True
Thanks!!
Milind
--
Dave Peterson
|