I wrote some script that runs through worksheets named 1 through 31 and copies a set range from each worksheet to the next available cell on a worksheet named "Camp Track Sheet". Instead of the code recognizing the sheet name it pulls data from the sheet numbers so I am getting some wrong data pulled into the "Camp Track Sheet: worksheet.
The code is as follows:
Private Sub CommandButton1_Click() Application.ScreenUpdating = True Dim sheetn As Integer Dim clearr As String sheetn = 1 Range("A5:G1123").Select 'STARTS OFF ON THE CAMP TRACK SHEET" Selection.ClearContents Do Until sheetn = 32 sheets(sheetn).Select [B] 'THIS CODE SELECTS THE WORKSHEET NUMBER, NOT THE WORKSHEET NAME WHICH I WANT[/B] sheets(sheetn).Range("A5:G1000").Select [B] 'THIS CODE SELECTS THE DATA ON THE WORKSHEET NUMBER, NOT THE WORKSHEET NAME WHICH I WANT TO COPY[/B] Selection.Copy sheets("Camp Track Sheet").Select Range("B1048576").Select Selection.End(xlUp).Select Selection.Offset(1, -1).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False sheetn = sheetn + 1 Loop Range("B1048576").Select Selection.End(xlUp).Select Selection.Offset(1, -1).Select clearr = ActiveCell.Address & ":G1048576" Range(clearr).Select Selection.Clear End Sub
What am I missing?