select a range on another sheet

T

Tonso

Using xl2000 for Windows, I want to... 1. click a macro button on the
'Inputs' sheet, then have the macro select the 'Calc' sheet. 2.
Starting at G4 on the Calc sheet, I want to select a range all the way
down to the last cell in G that has a value in it. The problem is, the
last cell might be in row 40, or row 42, etc., depending on how many
cells were copied over to column G n the Calc sheet. How can I make a
macro do this (select a range from G down to the last row, for
example, G4:G44, automatically without manually selecting the rows. As
information, there are no blank cells from G4 down to the last row so
End(xldown) would seem to be the way to go.. When I try it, it just
selects the last cell in the row, and not the range from G4 down to
the last cell in the row.

Thank you,

Tonso
 
D

Dave Peterson

Option Explicit
Sub testme()

dim Wks as worksheet
dim LastRow as long

set wks = worksheets("Calc")

with wks
lastrow = .cells(.rows.count,"G").end(xlup).row
application.goto .range("g4:G" & lastrow), scroll:=true
end with
End sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top