Solved

Excel Macro: Defining Non Active Page

Posted on 2014-09-07
3
208 Views
Last Modified: 2014-09-07
Hello,

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

0
Comment
Question by:dabug80
[X]
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
3 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 40309136
Add the sheet name:

Dim lastrow As Long

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

Flyster
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 500 total points
ID: 40309142
Try:

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
0
 
LVL 1

Author Closing Comment

by:dabug80
ID: 40309199
Thanks for your help
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

739 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