我有一个工作簿,上面有几张 table 。我想首先将工作表中的所有行聚合到主表中。我希望它是动态的,因此当我将一行添加到其他工作表之一时,它会将行添加到主表中。这是我的 Sub 的代码:
Public Sub AggregateIssues()
For pgNum = 1 To ActiveWorkbook.Sheets.Count
If ActiveWorkbook.Sheets(pgNum).Name = "Main" Then
currSheet = ActiveWorkbook.Sheets(pgNum) 'Get Sheet
flag = True
RowIndex = 0
While currSheet.Tables(0).Rows(RowIndex).Cells(0).Text = Null Or currSheet.Tables(0).Rows(RowIndex).Cells(0).Text = ""
Row = currSheet.Tables(0).Rows(RowIndex)
ActiveWorkbook.Sheets("Main").Tables("MainTbl").Append (Row)
RowIndex = RowIndex + 1
Next
End If
Next pgNum
End Sub
Sub or function is not defined
.该错误是在子名称上引发的。这是定义。当然,它还没有定义。关于为什么会发生这种情况的任何想法?continue
引起的。关键词。有没有continue
VBA中的关键字?
最佳答案
continue
在 VBA 中不使用 - 您可以改为包装 if
围绕主循环中的代码。break
也不是 VBA 语句 - 你可能想要 Exit
代替那个。
关于VBA:在 Excel 中创建宏 - 编译错误 -- 'Sub or function is not defined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11853149/