I have a workbook with several sheets with tables on them. I want to aggregate all the rows from the sheets onto the main table in the first. I would like it to be dynamic, so that when I add a row to one of the other sheets, it adds the row to the main table. Here is the code for my 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
Currently, I am getting a compile error: Sub or function is not defined. The error is thrown on the name of the sub. This is the definition. Of course it is not defined yet. Any ideas on why this is happening?
Note: I believe the error is actually be caused by the continue keyword. Is there a continue keyword in VBA?
continueis not used in VBA – you can instead wrap thatifaround the code in the main loop.breakis not a VBA statement either – you probably wantExitin place of that.