请教excel2007高手:怎样在excel2007里用宏语句选择这个未知单元格区域?

来源:百度知道 编辑:UC知道 时间:2024/06/27 16:23:11
未知单元格区域为"AA10:★10"(★是未知列标,指的是第6行里从单元格AA6起从左至右的最后一个带数值的单元格的列标)

Sub Macro1()
Dim x As Integer
Dim y As String
x = Range("AA6:VI6").End(xlToRight).Column '得到列号(数字)
y = Application.WorksheetFunction.Substitute(Left(Cells(1, x).Address, Len(Cells(1, x).Address) - 1), "$", "") '得到列标(英文字母)

End Sub