【发布时间】:2016-10-26 05:23:15
【问题描述】:
我需要列中第一个空单元格的名称,例如“E15”或“A3” 我试过使用 worksheet.Cells.Name 和 worksheet.Rows.Name 但我没有 认为这是正确的语法...请帮助!
这是我的代码
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(eXe)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
Dim eColumn As Excel.Range = xlWorkSheet.Range("E2:E15")
Dim rCell As Excel.Range
For Each rCell In eColumn
If rCell Is Nothing Then
Dim LastCell As String = xlWorkSheet.Rows.Name
MsgBox(LastCell)
End If
MsgBox(rCell.Value)
Next rCell
(更新)
我用下面的代码得到了$E$15,有没有办法得到不带“$”符号的地址?
For Each rCell In eColumn
If rCell.Value = "" Then
Dim LastCell As String = rCell.Cells.Address
MsgBox(LastCell)
End If
MsgBox(rCell.Value)
Next rCell
【问题讨论】:
-
.Address是您要找的吗? -
您使用的是 vb.net 还是 vba?从我的帽子顶部没有尝试它:因为你正在迭代ever
-
为什么不使用替换和删除$?
-
类似:MsgBox(LastCell.replace("$", "")
标签: vb.net excel visual-studio worksheet