简体   繁体   English

如何使用MACROS(VBA)获取excel中最后一个非空单元格的地址

[英]How to get adress of last non empty cell in a excel using MACROS(VBA)

I want to get the cell address of the last non empty cell within an excel sheet. 我想获取Excel工作表中最后一个非空单元格的单元格地址。 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. 我找到了很少的激光器来找出最后一个非空单元格中的值,但我需要单元格地址而不是内容。

For data like: 对于以下数据:

xsdew

Most people would like to find the Blue cell: 大多数人都想找到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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Excel VBA 检测非空的最后一个单元格位置 - Detect non empty last cell location using Excel VBA 如何使用Java从Excel工作表中获取特定列名(作为参数传递)的最后一个非空单元格的行索引? - How to get the row index of last non-empty cell for a specific column name(passed as an argument) from an excel sheet using java? 获取行中的最后一个非空单元格,或获取Excel中带有非空标题的最后一列 - Get last non-empty cell in a row or get last column with a non-empty header in Excel VBA(Excel):获取范围中的最后一个非空行 - VBA (Excel): Get last non-empty row in a Range 获取Excel列中的最后一个非空单元格 - Get last non-empty cell in Excel column 以编程方式获取Excel列的最后一个非空单元格 - Get Last non Empty Cell of Excel Column Programatically 使用excel公式查找非空单元格的最后一行 - Find last row of non empty cell using excel formula VBA Excel:在另一个工作簿上获取单击的单元格地址 - VBA Excel: Get the clicked cell´s adress on another workbook 即使在Excel VBA中即使中间有空白单元格,也要查找最后一个非空单元格中包含的值 - Finding the value containing in the last non empty cell even if there is blank cell in the middle in excel vba 如何在Excel 2010中使用VBA连续找到最后一个彩色和空白单元格? - How can I find the last colored & empty cell in a row using VBA in Excel 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM