Simpatie.ro - matrimoniale
Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Nou pe simpatie:
mariana_n23 pe Simpatie
Femeie
24 ani
Brasov
cauta Barbat
29 - 52 ani
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides /

[EXCEL] Go To Last Used Cell in Selected Column [VBA]

Pagini: 1 Moderat de TRaP, TonyTzu
#1
TRaP
Moderator
Postari: 960
I wanted to create an arrow shape and assign to it a macro to go to last used cell in the selected column.

Assuming you select a cell in column C and click the arrow button, you should go to last used cell / first unused cell in column C.

The following code goes to last used cell in column (equivalent to CTRL+DOWN ARROW press):


Sub GoToLastUsedCell()

Dim LastCell As String

LastCell = ActiveCell.End(xlDown).Address
LastCell = Range(LastCell).Select

End Sub


 
   
#2
TRaP
Moderator
Postari: 960
More complicated code:



Sub GoToLastRowCell()

Dim c As Range
Dim LastRow, colNum As Long

With ActiveSheet
    Set c = Selection
    colNum = c.Columns.Column
    LastRow = .Cells(Rows.Count, colNum).End(xlUp).Row
    .Cells(LastRow, colNum).Select
End With

End Sub


NOTE: IF YOU ARE USING A TABLE, IT WILL GO TO THE LAST CELL IN THE TABLE, NOT THE LAST CELL WITH DATA


 
   
Pagini: 1  
Mergi la