Đôi khi bạn cần code để tìm ra dòng cuối cùng hoặc cột cuối cùng để giải quyết bài toán.
Dưới đây là code cho bạn giải quyết vấn đề ấy.
Sub Range_End_Method()
'Finds the last non-blank cell in a single row or column
Dim DongCuoi As Long
Dim CotCuoi As Long
'Find the last non-blank cell in column A(1)
DongCuoi = Cells(Rows.Count, 1).End(xlUp).Row
'Find the last non-blank cell in row 1
CotCuoi = Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox "Last Row: " & lRow & vbNewLine & _
"Last Column: " & lCol
End Sub
No comments:
Write nhận xét