• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1215
  • Last Modified:

Excel .end(xlUp) fails

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
0
spitcha
Asked:
spitcha
1 Solution
 
nutschCommented:
dim rInt as a long instead, you probably have more than the 32 some thousands supported by the integer data type.
0
 
spitchaAuthor Commented:
Thanks for the reply. I get the same error after changing rInt to long
0
 
FlysterCommented:
See if this will work:

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

Flyster
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
spitchaAuthor Commented:
Nope. Still getting the same error.
0
 
spitchaAuthor Commented:
The issue is with end(xlUp). I'm able to select or get any value, leaving this query out.
0
 
NorieVBA ExpertCommented:
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

0
 
spitchaAuthor Commented:
Adding this line fixed the issue.
Thanks much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now