Forum Discussion

Excel's avatar
Excel
Iron Contributor
Sep 07, 2022

Question related to VBA code.

Hello Everyone, 

 

 I want something different in VBA code. 

 

Like if I have data in A Column from A1 to A13 and

in B Column, the data is from B1 to B4 and B6 to B8

 

If I will apply VBA - Range(ActiveCell, ActiveCell.End(xlDown)).Select, it will only select data from B1 to B4.

 

But I want to select data from B1 (ActiveCell) to B13 (Last used row in that worksheet)

 

It can be done by ASAP Utilities.

ASAP > Select > 9.Extend Selection to the last used row

 

Please help..??

 

Here is a attached file...

 

  • Excel 

    Sub SelectToLastRow()
        Dim LastRow As Long
        LastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        Range(ActiveCell, Cells(LastRow, ActiveCell.Column)).Select
    End Sub

Share