如何使用MACROS(VBA)获取excel中最后一个非空单元格的地址 [英] How to get adress of last non empty cell in a excel using MACROS(VBA)
本文介绍了如何使用MACROS(VBA)获取excel中最后一个非空单元格的地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取Excel表格中最后一个非空单元格的单元格地址。基本上我想要最后一个非空单元格的行和列号/名称。我发现很少有人找到最后一个非空的单元格中的值,但是我需要单元格的地址不是内容。
I want to get the cell address of the last non empty cell within an excel sheet. Basically I want the row and column number/name of the last non empty cell. I have found few ansers to find out the value in the last non empty cell but I need cell adress not contents.
推荐答案
数据如:
大多数人都想找到蓝色单元格:
Most people would like to find the Blue cell:
Sub FindBlue()
Dim rng As Range
Set rng = Cells.Find(What:="*", After:=Cells(1), SearchDirection:=xlPrevious, searchorder:=xlByRows)
MsgBox rng.Address(0, 0)
End Sub
如果你想然后,黄色单元格:
If you want the Yellow cell then:
Sub FindYellow()
Dim rng As Range
Set rng = Cells.Find(What:="*", After:=Cells(1), SearchDirection:=xlPrevious, searchorder:=xlByColumns)
MsgBox rng.Address(0, 0)
End Sub
这篇关于如何使用MACROS(VBA)获取excel中最后一个非空单元格的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文