ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-time error 1004 (https://www.excelbanter.com/excel-programming/350225-run-time-error-1004-a.html)

dthmtlgod

Run-time error 1004
 
I keep on getting the error above at the end of my routine. I use the same
routine on many other types of reports, however, I don't get the error on
those reports. I can't figure it out. Any ideas?

x = 2
i = 5

Sheets("L001.TXT").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:AA65536").Select
Selection.ClearContents
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False

y = Range("L001.TXT!G" & Rows.Count).End(xlUp).Row + 1 'Assumes nothing
beneath the
Range("L001.TXT!G" & y).Value = "X"

Sheets("MAIN").Select
Range("A1").Select

Application.StatusBar = "Loading data ...."

Do While Range("L001.TXT!G" & X) < "X"
If Range("L001.TXT!B" & X) = "OFF" Then
Do While Len(Range("L001.TXT!G" & X + 1)) 0
Range("IRES!J" & i).Value = "023"
Range("IRES!D" & i).Value = Format(Range("L001.TXT!B" & X + 1),
"000") & Format(Range("L001.TXT!D" & X + 1), "000") & "C"
Range("IRES!A" & i).Value = Date
Range("IRES!B" & i).Value = "IRES"
Range("IRES!H" & i).Value = "OPEN"
Range("IRES!I" & i).Value = "1ST"
Range("IRES!E" & i).Value = "N/A"
Range("IRES!F" & i).Value = "POLICY: " & Range("L001.TXT!G" & X
+ 1).Value
i = i + 1
X = X + 1
Loop
End If
X = X + 1
Loop



dthmtlgod

Run-time error 1004
 
I figured it out. It was jumping over my "X" check and going to the button
of the spreadsheet.


"dthmtlgod" wrote in message
...
I keep on getting the error above at the end of my routine. I use the same
routine on many other types of reports, however, I don't get the error on
those reports. I can't figure it out. Any ideas?

x = 2
i = 5

Sheets("L001.TXT").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:AA65536").Select
Selection.ClearContents
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False

y = Range("L001.TXT!G" & Rows.Count).End(xlUp).Row + 1 'Assumes nothing
beneath the
Range("L001.TXT!G" & y).Value = "X"

Sheets("MAIN").Select
Range("A1").Select

Application.StatusBar = "Loading data ...."

Do While Range("L001.TXT!G" & X) < "X"
If Range("L001.TXT!B" & X) = "OFF" Then
Do While Len(Range("L001.TXT!G" & X + 1)) 0
Range("IRES!J" & i).Value = "023"
Range("IRES!D" & i).Value = Format(Range("L001.TXT!B" & X + 1),
"000") & Format(Range("L001.TXT!D" & X + 1), "000") & "C"
Range("IRES!A" & i).Value = Date
Range("IRES!B" & i).Value = "IRES"
Range("IRES!H" & i).Value = "OPEN"
Range("IRES!I" & i).Value = "1ST"
Range("IRES!E" & i).Value = "N/A"
Range("IRES!F" & i).Value = "POLICY: " & Range("L001.TXT!G" & X
+ 1).Value
i = i + 1
X = X + 1
Loop
End If
X = X + 1
Loop






All times are GMT +1. The time now is 12:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com