combining Xcell sheets into one HOW

wan2fly99

Registered User.
Local time
Today, 11:13
Joined
Feb 7, 2005
Messages
53
I found this code to copy all sheets ina spreadsheet into one
It works until a certain limit and then stops

I don't know much about vba excel so any help would be appreciate

I have 4 sheets and trying to combine them all into one sheet

Sub Combine()
Dim J As Integer

On Error Resume Next
Sheets(1).Select
Worksheets.Add ' add a sheet in first place
Sheets(1).Name = "Combined"

' copy headings
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")

' work through sheets
For J = 2 To (Sheets.Count + 1) ' from sheet 2 to last sheet
Sheets(J).Activate ' make the sheet active
Range("A1").Select
Selection.CurrentRegion.Select ' select all cells in this sheets

' select all lines except title
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select

' copy cells selected in the new sheet on last line
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)

Next
End Sub
 
Change this
For J = 2 To (Sheets.Count) ' from sheet 2 to last sheet

This seems to work ok.
With this I don't get two copies of the last sheet.
 

Users who are viewing this thread

Back
Top Bottom