Solved

Excel Macro: Defining Non Active Page

Posted on 2014-09-07
3
206 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
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 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

Industry Leaders: 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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

680 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