title: How to offset in a "For each loop"
body: <p>In a nested loop, I am trying to figure out how to indicate that the results should go in a different column for the second and third worksheets in the array. For the first worksheet in the array, everything is good. For the second and third worksheets, I need to place the result in the next column over. I'm just not sure WHERE to say that so that it doesn't mess up the "nested" part of the loop. </p>
  
  <p>I was feeling pretty proud of myself for writing a nested loop until it didn't work. Finally, I realized that it was technically working, but that the loop was replacing the same cells of the same column over and over again because I didn't specify that the result should go over by one column. I found this <a href="https://stackoverflow.com/questions/56380209/vba-for-each-loop-incrementing-offset-by-1-column">answer about offsetting</a> that looked promising but it is a little over my head. </p>
  
  <pre><code>Dim SG As Worksheet, SG2017 As Worksheet, SG2018 As Worksheet, SG2019 As Worksheet
      Set SG = Workbooks("Subgroup Summary Template").Sheets("SG")
      Set SG2017 = Workbooks("2017 Subgroup Summary").Sheets("2017")
      Set SG2018 = Workbooks("2018 Subgroup Summary").Sheets("2018")
      Set SG2019 = Workbooks("2019 Subgroup Summary").Sheets("2019")
  Dim SGdata As Variant
  Dim CurrentSGdata As Variant
      SGdata = Array(SG2017, SG2018, SG2019)
  Dim i As Long
  
  'ALL STUDENTS
  For Each CurrentSGdata In SGdata
      With CurrentSGdata.Range("A1")
           For i = 3 To 8
           .AutoFilter Field:=7, Criteria1:=i
           .AutoFilter Field:=8, Criteria1:="Total Population"
           .AutoFilter Field:=1, Criteria1:=school
                  SG.Cells(i, 3) = CurrentSGdata.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Columns(15).Cells(1, 1)
                      On Error Resume Next
                  SG.Cells(i, 6) = CurrentSGdata.UsedRange.SpecialCells(xlCellTypeVisible).Areas(2).Columns(17).Cells(1, 1)
                      On Error Resume Next
              CurrentSGdata.AutoFilterMode = False
           Next i
  Next CurrentSGdata
  </code></pre>
  
  <p>For example, how do I indicate that in the second iteration of <code>"CurrentSGdata,"</code> the <code>SG.Cells(i,3)</code> should become <code>SG.Cells(i,4)</code>? </p>