Excel Macro: Defining Non Active Page

Posted on 2014-09-07
Medium Priority
Last Modified: 2014-09-07

I have the following line of code. I would like to define that the lastrow range is from another (non active sheet) named 'Unique ID'. How would I modify the code in line 3?

Dim lastrow As Long

    lastrow = Range("F" & Rows.Count).End(xlUp).Row

Open in new window

Question by:dabug80
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 22

Expert Comment

ID: 40309136
Add the sheet name:

Dim lastrow As Long

    lastrow = Range("UniqueID!F" & Rows.Count).End(xlUp).Row

LVL 50

Accepted Solution

Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 2000 total points
ID: 40309142

Sub test()
Dim lastrow As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("UniqueID")

    lastrow = ws.Range("F" & Rows.Count).End(xlUp).Row
    MsgBox lastrow

End Sub

Open in new window

@Flyster, your suggestion does not work in a sheet module.

cheers, teylyn

Author Closing Comment

ID: 40309199
Thanks for your help

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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 …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

752 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