EXCEL:获取某列或得中最后一个非空单元格的行数和数值
一、A列中最后一个非空单元格是
Sub LastRow()
Dim rng As Range
Set rng = Sheet1.Range("A65536").End(xlUp)
MsgBox "A列中最后一个非空单元格是" & rng.Address(0, 0) _
& ",行号" & rng.Row & ",数值" & rng.Value
Set rng = Nothing
End Sub
二、第一行中最后一个非空单元格是
Sub LastColumn()
Dim rng As Range
Set rng = Sheet1.Range("IV1").End(xlToLeft)
MsgBox "第一行中最后一个非空单元格是" & rng.Address(0, 0) _
& ",列号" & rng.Column & ",数值" & rng.Value
Set rng = Nothing
End Sub