last day (14 days later) » 

9:35 AM
0
Q: Runtime Error '1004'

user3800275Good day, I am trying to run this Macro, but always get a Runtime Error '1004' Message Dim clLookup As Range Dim clDest As Range Dim rws As Long With wbk2.Sheets("SOA") Set clDest = .Range("J2") Set clLookup = .Range("G2") End With If clLookup.Offset(1, 0) <> vbNullString Then rws = Range(clL...

 
Is wbk2 set anywhere? Error 1004 could indicate that you try to use an object that hasn't been initialized
 
hi, yes it is and the sheet is usually open when the error occurs. Just for reference though: Dim wbk2 As Workbook 'NEW SHEET
The weird thing is that the same code works on other sheets; but its just this one that is not, driving me crazy for almost an hour now :)
 
Check if the sheet is protected
 
It's not, I My macro basically creates a new sheet and calls it "Wkb2" with Worksheet ("SOA"). Got you confused as well no? LOL Hate when stupid things take so much time to figure out !!
 
Yes, I'm quite confused. so at what line the code stops?
 
9:35 AM
At this line "If clLookup.Offset(1, 0) <> vbNullString Then"
Although i do not get any "highlight" of the error, but when i check line by line, the one above is where it stops... No idea why. Is there a way i can upload my file? the code is quite long and would not want to past it here
 
change the line with clLookup.Offset(1, 0).Value <> vbNullString
regarding uploading a file, try a public file hosting service (like dropbox, onedrive) and post the link
 
9:56 AM
Hi, sorry was away
 
no problem. let me know when you try the above line of code
 
I will upload the file to Dropbox
Tried the code, no use :(
Basically there are 2 files:
1. SOA Generator, which runs the macro
2. Receivable, which is the file it will be reading from
 
SOA file doesn't have the code
xlsx files don't allow macros, try saving as xlsm
and upload it again
 
it is "xlsm" LOL
okay wait let me check, but on my desktop its xlsm
ill zip it
maybe dropbox doesnt allow, not sure
Btw, didnt get to thank you for your time spent helping, truly appreciated :)
 
10:22 AM
no problem :)
it seems that the problem is at this line
Range(clLookup, clLookup.End(xlDown)).Rows.Count
you try to use an invalid range
Range belongs to the current sheet, because you are in SoaGenerator sheet, this fails
try wbk2.Range(clLookup, clLookup.End(xlDown)).Rows.Count
 
hmmm, yes sounds very logical
It worked
I added
wbk2.Sheets("SOA").Range(clLookup, clLookup.End(xlDown)).Rows.Count
:D
awesome !!!
Fewww, what a reliefff
Honestly, THANK YOU SO MUCH !!
 
good :)
 
Can you post the answer to the question and i can mark it as answered
for the points + for reference to anyone that might face this issue in the future
 
ok, i will write it now
 

last day (14 days later) »