azizrasul
Well-known Member
- Joined
- Jul 7, 2003
- Messages
- 1,304
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
I have the following code which I use with sheet T4 copied in from different monthly files. The code works fine except when I use T4 sheet for the June data it doesn't. The code simply tries to find which row the country codes begin. The country codes are
GBR
DEU
etc.
I get the error 1004 (Method range of object global failed if I comment out line On Error Resume Next.
GBR
DEU
etc.
I get the error 1004 (Method range of object global failed if I comment out line On Error Resume Next.
Code:
Sheets("T4").Select
For iCol = 1 To ActiveSheet.UsedRange.Columns.Count
If intCountryLine > 0 Then
Exit For
End If
For x = 1 To ActiveSheet.UsedRange.Rows.Count
strCountryCode = Cells(x, iCol)
On Error Resume Next
varResult = Application.WorksheetFunction.Match(strCountryCode, Range("CountryCodes"), 0)
If Err = 0 Then
intCountryLine = x
y = iCol
Exit For
End If
On Error GoTo 0
Next x
Next iCol