I am trying to write code to copy certain ranges of data from each sheet to a summary sheet. I have attempted many versions of this (far too many for me to put them all here), but with each one the summary sheet has empty values. I don't understand what is going wrong, and I have no theories.
Here is the version that I wrote myself. All of the other variations I tried were found on the Internet:
Note: The actual summary sheet is created elsewhere in code. Also, the reason why I have sheetIndex starting at 6 is because that's the first sheet I want to take data from.
Sub PopulateSummary()
Dim nmbrParts As Integer
Dim partIndex As Integer
Dim sheetIndex As Integer
Dim sheetCount As Integer
sheetCount = ThisWorkbook.Sheets.Count
for sheetIndex = 6 To sheetCount
With Sheets(sheetIndex)
.Activate
.Range("B2").Select
Call SelectFirstToLastInColumn
nmbrParts = Selection.Count
Sheets("Summary").Activate
for partIndex = 1 To nmbrParts
row = partIndex + 1
Sheets("Summary").Cells(row, 1).Value = .Cells(row, 1).Value
Sheets("Summary").Cells(row, 2).Value = .Cells(row, 2).Value
Sheets("Summary").Cells(row, 3).Value = .Cells(row, 4).Value
Sheets("Summary").Cells(row, 3).Value = .Cells(row, 3).Value
Sheets("Summary").Cells(row, 5).Value = .Cells(row, 6).Value
Next partIndex
End With
Next sheetIndex
End Sub
EDIT: I figured something out. Since I'm invoking these macros from another workbook, I changed ThisWorkbook to ActiveWorkbook, so it counts the right number of sheets. The problem isn't solved, though.