Sub test002()
Dim rng As Range
Dim tem_rng
Dim i&
Dim temp%: temp = 0
For i = 1 To Sheet1.UsedRange.Rows.Count
Set rng = Sheet1.Range("IV" & i).End(xlToLeft)
If rng.Column > temp Then
temp = rng.Column
Set temp_rng = rng
End If
Next i
msgbox "本行,最后一个非空单元格所在的列最大!第" & temp_rng.Row & "行,第" & temp_rng.Column & "列"
msgbox "本列,最后一个非空单元格所在的行最大!第" & rng.Row & "行,第" & rng.Column & "列"
End Sub
测试了一下结果正确,你自己再试试吧
此外:
a为string类型
a=rng.Address(0,0) '返回相对地址,格式为 B1
a =rng.Address(1,1) '返回绝对地址,格式为$B$1