使用变量名调用工作表

使用变量名调用工作表

我有这段代码,其中我添加了一个具有特定名称的工作表,然后我需要调用这个工作表来获取单元格值,但它没有假设。

Dim nome1 As String
Dim tableName As ListObject
Dim addedRow As ListRow

'To add a sheet with a specific name
nome1 = InputBox("Name of the sheet?")
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = nome1

'For adding a row to table 1 and add value to the first cell
'The table1 is in a differente sheet then the sheet nome1

Set tableName = ActiveSheet.ListObjects("Table1")
Set addedRow = tableName.ListRows.Add()
With addedRow
    .Range(1) = "='nome1'!R1C3"
End With

'它没有获取带有变量‘nome1’的工作表!

相关内容