-
Jul 14th, 2011, 01:32 PM
#1
Thread Starter
Member
[Excel VBA] Run-time error '1004'
I am getting this error
Run-time error '1004':
Application-defined or object-defined error
at this line of code:
Code:
NumVehTotal = Workbooks(DataFile).Worksheets("Data"). _
Range("A2", Range("A" & EXCEL_MAX_ROWS + 2).End(xlUp)).Rows.Count
The constant EXCEL_MAX_ROWS is 65000, and there are about 3500 rows of data, so I don't think there is any problem with getting a row number out of the correct range, like 65538. If I select some cell in column A, say A5000, and hit Ctrl-Up, it selects the last row of Data. So, I think the End(xlUp) should be working as I expect.
In fact, when I run this program on one network drive, it works fine. When I run it on another network drive (I change the corresponding directories), I get this error. DataFile is the name of the workbook, including .xlsm, and I use that same string variable to open the file, so I don't see that causing any problems.
I have no idea what's going on. Any help would be greatly appreciated.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|