I have a code which consolidates a specific sheet from multiple workbooks where the sheet name of the opened file is always a number from 1-30. Right now, I have to indicate the sheet name/number one at a time. Is there a way to do it like 3 or 7 times? like a loop? e.g 1-7 or 25-27.. It is always ascending so i thought a code like the one below will work? Thoughts?
For sName = sNameStart To sNameEnd
Sheets(sName).Activate
On Error GoTo 0
Range("d11:j11").Select
Range(Selection, Selection.End(xlDown)).Copy
ThisWorkbook.Sheets("Sheet1").Activate
Range("b2").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.PasteSpecial Paste:=xlPasteValues
Next sName
where sName is the sheet name, sNameStart is the start sheet and sNameEnd is the end sheet. However, i get there's this error when I start this code.. Help?
Addendum:
sName is a number that is always ascending and sNameStart and sNameEnd are both ranges indicated as range("i1") and range("k1") respectively.