Hello, I need help with how my VBA code works. I am trying to copy data from multiple worksheets (variable number and names) into a single "Combined" worksheet. This is proving more difficult because there are hidden worksheets that I can't change and "Template" sheet only has one row of data so using "Range(Selection, Selection.End(xlDown)).Copy" for that worksheet wouldn't work... Thus I have my code doing the "Template" sheet first and then doing the loop, however my code only does it on the "Combined" sheet and ignore my <> "Combined".
Can someone explain why this doesn't work and potentially help me fix it. Thank you!!
PS
I think it has something to do with using select? But I am trying to learn how to avoid using it so any tips on that end would be really appreciated...
Can someone explain why this doesn't work and potentially help me fix it. Thank you!!
PS
I think it has something to do with using select? But I am trying to learn how to avoid using it so any tips on that end would be really appreciated...
VBA Code:
Sub CP2Combined()
Dim Current As Worksheet
Sheets("Template").Range("C2:AH2").Copy
Sheets("Combined").Range("B3").Select
ActiveSheet.Paste
For Each Current In Worksheets
If Current.Visible = xlSheetVisible Then
If Current.Name <> "Combined" And _
Current.Name <> "Template" Then
Range("C2:AH2").Select
Range(Selection, Selection.End(xlDown)).Copy
Sheets("Combined").Select
Range("B" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
End If
End If
Next
End Sub