我已尝试过各种表达式来执行[似乎是]在两个工作表之间复制excel表的简单任务。另外,我需要将表达式括在循环中。这里有四个表达式(都以“表格”开头)我试过了。所有这些都编译,但在运行时崩溃:
p = 6
For i = 1 To NumTables
'Read "OP LLs" table into "EIRP budget"
Sheets("EIRP Budget").[B6:L17] = Sheets("OP LLs").Range(Cells(p, 2), Cells(p + 11, 12))
Sheets("EIRP Budget").[B6:L17] = Sheets("OP LLs").[Cells(p, 2), Cells(p + 11, 12)]
Sheets("OP LLs").Range(Cells(p, 2), Cells(p + 11, 12)).Copy Sheets("EIRP Budget").[B6]
Sheets("OP LLs").["B" & p & : & "L" & p + 11].Copy Sheets("EIRP Budget").[B6:L17]
p = p + 15
Next
非常感谢任何帮助。
答案 0 :(得分:1)
我怀疑你因为不合格的单元格而遇到困难(你没有指明单元格所指的工作表)
尝试(未测试):
dim wksCopyFrom as Worksheet
dim wksCopyTo as Worksheet
set wksCopyFrom = Sheets("OP LLs")
set wksCopyTo = Sheets("EIRP Budget")
For i = 1 To NumTables
p = 6
'Read "OP LLs" table into "EIRP budget"
wksCopyFrom.Range(wksCopyFrom.Cells(p,2), wksCopyFrom.Cells(p+11,12)).Copy wksCopyTo.Range("B6")
p = p + 15
Next