Find and Select the Last Row and Column

Ulisses_Carso

New Member
Joined
Sep 4, 2020
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hello Guys,

I'm trying to make select code tha finds the Last Row, then find and jump to the Last Column in the same Line and select that Cell

Example: i have 10 columns with 40 lines
Line A with Header, Column A with Data and the rest is blank

This way, the last cell is J40, but i don't know how to find and select that cell, I already tried to merge two codes that find the last row and column separately but no success.

VBA Code:
Sub FindLastRow()
    Dim LastRow As Long
    With ActiveSheet
        LastRow = .Cells(.Rows.Count, "A").End(xlUp).Select
    End With
End Sub

Sub FIndLasCol()
    Dim LastCol As Integer
    With ActiveSheet
        LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Select
    End With
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,990
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Sub UlissesCarso()
   Cells(Range("A" & Rows.Count).End(xlUp).Row, Columns.Count).End(xlToLeft).Select
End Sub
 

Ulisses_Carso

New Member
Joined
Sep 4, 2020
Messages
31
Office Version
  1. 365
Platform
  1. Windows
it worked well, but this way it selects the last row and/or last filled column, there is a chance that the last cell is blank.
Assuming that in my example cell J40 is blank, I need to select it anyway because after selecting ths cell i'll expand selection to "E2"
 

Ulisses_Carso

New Member
Joined
Sep 4, 2020
Messages
31
Office Version
  1. 365
Platform
  1. Windows
sorry, i did that code too but it's not the result that i need
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,990
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Ok, how about
VBA Code:
Sub UlissesCarso()
   With Range("a1").CurrentRegion
      Cells(.Rows.Count, .Columns.Count).Select
   End With
End Sub
 
Solution

Ulisses_Carso

New Member
Joined
Sep 4, 2020
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Thanks dude, now it worked perfectly
i'm feeling a little dumb, this code is so simple, kkk
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,990
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback.
 

Forum statistics

Threads
1,144,391
Messages
5,724,075
Members
422,535
Latest member
navjeet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top