我想在子程序之间传递工作表和范围的名称。以下内容将"下标超出范围"错误:
Sub This()
x = "Sheet1"
y = "D3"
MsgBox (x.Range(y).Value)
End Sub
答案 0 :(得分:0)
您的工作表.Name property 估值;其工作表.CodeName property是 Sheet1 。
dim x as string, y as string
dim xx as worksheet, yy as range
x = "Valuation"
set xx = worksheets(x)
y = "D3"
set yy = xx.range(y)
debug.print yy.address(0,0, external:=true) '<~~returns Valuation!D3 (with the workbook name)
debug.print Sheet1.name '<~~returns Valuation from CodeName