Excel .end(xlUp) fails

Posted on 2012-12-28
Last Modified: 2012-12-29
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.
Question by:spitcha
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 39

Expert Comment

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

Author Comment

ID: 38728690
Thanks for the reply. I get the same error after changing rInt to long
LVL 22

Expert Comment

ID: 38728728
See if this will work:

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.


Author Comment

ID: 38728740
Nope. Still getting the same error.

Author Comment

ID: 38728756
The issue is with end(xlUp). I'm able to select or get any value, leaving this query out.
LVL 34

Accepted Solution

Norie earned 500 total points
ID: 38728759
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 Closing Comment

ID: 38728764
Adding this line fixed the issue.
Thanks much!

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question