'workbooks.sheets.add'后'不工作

我正在尝试使用macros在特定工作表之后添加工作表。 我们假设这个工作表被命名为102014.我希望这个macros在名字为112014的102014之后创build一个工作表,但是我不能使用select或active工作表,因为它实际上是一个macros的一部分,我来回切换在工作簿之间。 这是我试图做的,没有成功:

dim wbname as string dim thismonth as string dim lastmonth as string thismonth = ThisWorkbook.Worksheets("Sheet2").Cells([address of a cell with the name of the sheet).Value lastmonth = ThisWorkbook.Worksheets("Sheet2").Cells([address of a cell with the name of the sheet).Value wbname = ThisWorkbook.Sheets("Sheet2").Cells([address of a cell with the file name here]) Workbooks(wbname).Sheets.Add(After = wbkname.Sheets(lastmonth)).Name = thismonth 

macros只是通过这最后一行,去到另一个,没有错误,没有什么。 正如你所看到的,我有一个包含表名和文件名的列表,这是我得到这个thismonthlastmonthwbnamevariables的地方。

我究竟做错了什么?

使用.Add(After:= ...

请注意所需的冒号。