lastrow excel

contoh script vba excel

lastrow excel

Last used cell in one row or one column

mencari cells terakhir yang berisi content dalam 1 row atau dalam 1 column

Sub LastRowInOneColumn()
<span class="vbatext">'Find the last used row in a Column: column A in this example</span>
    Dim LastRow As Long
    With ActiveSheet
        LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    End With
    MsgBox LastRow
End Sub

Sub LastColumnInOneRow()
<span class="vbatext">'Find the last used column in a Row: row 1 in this example</span>
    Dim LastCol As Integer
    With ActiveSheet
        LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    End With
    MsgBox LastCol
End Sub

 

Last used cell in a worksheet

mencari cells kontent terakhir dalam 1 worksheet

Last Row :

Sub xlCellTypeLastCell_Example_Row()
    Dim LastRow As Long
    With ActiveSheet
        LastRow = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
    End With
    MsgBox LastRow
End Sub

Sub UsedRange_Example_Row()
    Dim LastRow As Long
    With ActiveSheet.UsedRange
        LastRow = .Rows(.Rows.Count).Row
    End With
    MsgBox LastRow
End Sub

Last Column :

Sub xlCellTypeLastCell_Example_Column()
    Dim LastColumn As Long
    With ActiveSheet
        LastColumn = .Range("A1").SpecialCells(xlCellTypeLastCell).Column
    End With
    MsgBox LastColumn
End Sub

Sub UsedRange_Example_Column()
    Dim LastColumn As Long
    With ActiveSheet.UsedRange
        LastColumn = .Columns(.Columns.Count).Column
    End With
    MsgBox LastColumn
End Sub

 

tips menarik lain nya : send email via macro excel

indotrainer01

Leave a Reply

Your email address will not be published.

Penyedia Jasa Training Reguler, Public Training, Inhouse Training untuk MS Excel Basic