I get the run-time error: Method 'Range' of Object '_Global' Failed for the following code (CFFileName and FileName refer to different files)
Dim AccountNumber
Dim EndingBalance As Currency
Windows(CFFileName).Activate
Sheets(CFTabName).Select
For Count = StartRow To CFEndRow
AccountNumber = Range("C" & Count)
Windows(FileName).Activate
Sheets(TabName).Select
For SubCount = 2 To TotalRows
If Range("C" & SubCount) = "TOTALS:" Or Range("A" & SubCount) = AccountNumber Then
EndingBalance = Range("I" & SubCount)
Windows(CFFileName).Activate
Sheets(CFTabName).Select
Range("D" & Count) = EndingBalance
End If
Next
Next
The offending line is bolded. What can I do to fix this. Why do i get this error. What does this error mean. I have seen it come up for small things like missing quotation marks and for some really random reasons.
Thanks for your help.
Dim AccountNumber
Dim EndingBalance As Currency
Windows(CFFileName).Activate
Sheets(CFTabName).Select
For Count = StartRow To CFEndRow
AccountNumber = Range("C" & Count)
Windows(FileName).Activate
Sheets(TabName).Select
For SubCount = 2 To TotalRows
If Range("C" & SubCount) = "TOTALS:" Or Range("A" & SubCount) = AccountNumber Then
EndingBalance = Range("I" & SubCount)
Windows(CFFileName).Activate
Sheets(CFTabName).Select
Range("D" & Count) = EndingBalance
End If
Next
Next
The offending line is bolded. What can I do to fix this. Why do i get this error. What does this error mean. I have seen it come up for small things like missing quotation marks and for some really random reasons.
Thanks for your help.