Excel .end(xlUp) fails

spitcha
spitcha used Ask the Experts™
on
The sub writes messages in Outlook to an Excel file. I need the script to select to lastRow in the excel file but the line "rInt = xlWks.Range("A65536").End(xlUp).Row" errors.
ol-xl-error.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2008

Commented:
dim rInt as a long instead, you probably have more than the 32 some thousands supported by the integer data type.

Author

Commented:
Thanks for the reply. I get the same error after changing rInt to long
See if this will work:

rInt = .Cells(.Rows.Count, "A").End(xlUp).Row

Flyster
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Nope. Still getting the same error.

Author

Commented:
The issue is with end(xlUp). I'm able to select or get any value, leaving this query out.
Analyst Assistant
Commented:
xlUp is an Excel constant, you either need to use it's value,  -4162, or add a declaration for it.
Const xlUp = -4162

Open in new window

Author

Commented:
Adding this line fixed the issue.
Thanks much!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial