尝试这样的事情。您的问题有点不清楚,因为您既提到了最后一个单元格Address
(我想提取最后一个单元格的地址),又提到了一些关于Value
(我如何调用这些值)的内容。上面的代码将检索Address
最后一个单元格的值,但还包括检索值的代码,您只需注释掉一行并取消注释另一行。
Sub LastCellAddresses()
Dim Mar As Worksheet
Dim myValues As Variant
Dim i As Integer: i = 1
'## Create an Array with one item for each worksheet
ReDim myValues(1 To ActiveWorkbook.Worksheets.Count)
'## iterate the worksheets and add values to the array
For Each Mar In ActiveWorkbook.Worksheets
'## Use one of these, depending on what you're trying to do.
' This line returns the ADDRESS
myValues(i) = Mar.Cells.SpecialCells(xlCellTypeLastCell).Address
' OR this line returns the VALUES
'myValues(i) = Mar.Cells.SpecialCells(xlCellTypeLastCell).Value
i = i + 1
Next Mar
'## Print each value from the array in its own row, from
' the activeCell
' Modify as needed
ActiveCell.Resize(UBound(myValues)).Value = Application.Transpose(myValues)
End Sub