Move to last row of a particular column.

VijayNewtoExcel

New Member
Joined
Dec 14, 2024
Messages
3
Office Version
  1. 365
I want to go the cell of the last row of a particular column where the value has been entered. Can you please provide VBA Code/.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Sub GoToLastCellInColumn()
Dim ws As Worksheet
Dim lastRow As Long
Dim targetColumn As String

' Set your worksheet and target column
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name
targetColumn = "A" ' Change "A" to your desired column

' Find the last row in the target column with data
With ws
lastRow = .Cells(.Rows.Count, targetColumn).End(xlUp).Row
' Select the last cell in the column
.Cells(lastRow, targetColumn).Select
End With
End Sub
 
Upvote 0
@dlwlrma you need a ws.Activate line in that code or it will error if you are on any other sheet than ThisWorkbook.Sheets("Sheet1").... although it won't matter to the OP as they are already on the sheet.
 
Upvote 0
This macro applies to the active sheet.
VBA Code:
Sub SelectLastRow()
    Dim lCol As Long
    lCol = ActiveCell.Column
    Cells(Rows.Count, lCol).End(xlUp).Select
End Sub
 
Upvote 0
@VijayNewtoExcel if you want the code to automatically run when you change the cell can you narrow the range down to exactly what the particular column is so it isn't running on every cell change? or if you are searching for a specific value then please state it
 
Upvote 0
Sub GoToLastCellInColumn()
Dim ws As Worksheet
Dim lastRow As Long
Dim targetColumn As String

' Set your worksheet and target column
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name
targetColumn = "A" ' Change "A" to your desired column

' Find the last row in the target column with data
With ws
lastRow = .Cells(.Rows.Count, targetColumn).End(xlUp).Row
' Select the last cell in the column
.Cells(lastRow, targetColumn).Select
End With
End Sub
Superb....It worked....Appreciate your quick response
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,314
Members
453,032
Latest member
Pauh

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
Back
Top