Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Excel Macro: Defining Non Active Page

Posted on 2014-09-07
3
Medium Priority
?
228 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 (Microsoft MVP / EE MVE) earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
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…

581 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