Go to lastrow using other column's lastrow

  • Thread starter Thread starter stakar
  • Start date Start date
S

stakar

i have the following problem
I want to use the column's G lastrow and go to the lastrow of th
worksheet("A") activecolumn using a macro

Be more specific

last_row = Worksheets("A").Range("G65536").End(xlUp).Row

Using the last_row i want to go to the last_row of the activecolumn.
So if the last_row =120 and the activecolumn is "B" i want to go to th
cell 'B120'

Thanks in advance
Stathi
 
Hi
try
LastRow = ActiveSheet.Cells(Rows.Count,
activecell.column).End(xlUp).row

or
ActiveSheet.Cells(Rows.Count, activecell.column).End(xlUp).select
 
stakar,

This will select the cell that's in the same column as the current selection
and the same row as the last used row in column G:

Sub test()

Dim last_row As Long

last_row = Worksheets("A").Range("G" & Rows.Count).End(xlUp).Row
Worksheets("A").Cells(last_row, ActiveCell.Column).Select

End Sub

hth,

Doug
 
more consistent would be

Sub test()

Dim last_row As Long

last_row = Range("G" & Rows.Count).End(xlUp).Row
Cells(last_row, ActiveCell.Column).Select

End Sub

Unless you want to base the last row on a sheet other than the active sheet.

--
Regards,
Tom Ogilvy


Doug Glancy said:
stakar,

This will select the cell that's in the same column as the current selection
and the same row as the last used row in column G:

Sub test()

Dim last_row As Long

last_row = Worksheets("A").Range("G" & Rows.Count).End(xlUp).Row
Worksheets("A").Cells(last_row, ActiveCell.Column).Select

End Sub

hth,

Doug
 
Tom,

NoI was trying to respond to what seems to be the OP's specification of
using Worksheet "A" both in the specification of last_row and in the Select.
I see now that it doesn't work if Activecell is in other than Worksheet "A".
Don't know if OP really wants to always go to "A", but if so, how's this?

Sub test()

Dim last_row As Long

last_row = Worksheets("A").Range("G" & Rows.Count).End(xlUp).Row
Application.Goto reference:=Worksheets("A").Cells(last_row,
ActiveCell.Column)

End Sub


Doug

Tom Ogilvy said:
more consistent would be

Sub test()

Dim last_row As Long

last_row = Range("G" & Rows.Count).End(xlUp).Row
Cells(last_row, ActiveCell.Column).Select

End Sub

Unless you want to base the last row on a sheet other than the active sheet.
 

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

Back
Top