title: Loop to insert rows to tables across multiple sheets
body: <p>I'm working on a loop to go through a series of worksheets in my workbook and add a row (or two) to the table on that worksheet if the date associated with that worksheet is the same or after the selected date. I made a table with the sheet names, dates, and table names that the code could loop through ("Lists" referenced in the code). However, nothing happens when I run the code. Should I add a Do While statement or nest these differently?</p>
  
  <pre><code>Private Sub CmdBttn2_Click()
  Dim TxtBxAddDate As Date 'Is this necessary?
  Dim ws As Worksheet
  Set ws = Worksheets("Lists")
  
  
  'Loop over list of sheets??
      Dim i As Integer
          For i = 1 To 31 'loop through rows 1 to 31
          If TxtBxAddDate &gt;= ws.Cells(i, 21).Value Then 'Compare date to date on sheet list in column U
          Sheets(ws.Cells(i, 20).Value).Select 'Find sheet name in column T
             If ChkBxLAC01 = True And ChkBxLAC02 = True Then 'Add to both modules
                   newrowA = Worksheets(ws.Cells(i, 20).Value).ListObjects(ws.Cells(i, 22).Value).ListRows.Add(2)  'Add row to table in sheet
                   With newrowA
                   'Add module 1 info to row 5
                      ws.Cells(5, 3).Value = "Yes" 'Enabled
                      ws.Cells(5, 4).Value = "1" 'Module 1
                      ws.Cells(5, 5).Value = TxtBxNewAnalyte 'Assay name
                   'Add module 2 info to row 6
                      ws.Cells(6, 3).Value = "Yes" 'Enabled
                      ws.Cells(6, 4).Value = "2" 'Module 2
                      ws.Cells(6, 5).Value = TxtBxNewAnalyte 'Assay name
                   End With
                   MsgBox TxtBxNewAnalyte &amp; " added to modules 1 and 2.", vbOKOnly
                ElseIf ChkBxLAC01 = True And ChkBxLAC02 = False Then 'Add to module 1, not 2
                   newrowB = Worksheets(ws.Cells(i, 20).Value).ListObjects(ws.Cells(i, 22).Value).ListRows.Add(1)  'Add row to table in sheet
                   With newrowB
                      ws.Cells(5, 3).Value = "Yes" 'Enabled
                      ws.Cells(5, 4).Value = "1" 'Module 1
                      ws.Cells(5, 5).Value = TxtBxNewAnalyte 'Assay name
                   End With
                   MsgBox TxtBxNewAnalyte &amp; " added to module 1.", vbOKOnly
                ElseIf ChkBxLAC01 = False And ChkBxLAC02 = True Then 'Add to module 2, not 1
                   newrowC = Worksheets(ws.Cells(i, 20).Value).ListObjects(ws.Cells(i, 22).Value).ListRows.Add(1)  'Add row to table in sheet
                   With newrowC
                      ws.Cells(5, 3).Value = "Yes" 'Enabled
                      ws.Cells(5, 4).Value = "2" 'Module 2
                      ws.Cells(5, 5).Value = TxtBxNewAnalyte 'Assay name
                   End With
                   MsgBox TxtBxNewAnalyte &amp; " added to module 2.", vbOKOnly
                Else
                MsgBox "No modules selected!", vbExclamation
                GoTo NxtTbl
             End If
             Else
             GoTo NxtTbl
          End If
  NxtTbl:
          Next
  
  
  End Sub
  </code></pre>