Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag for Ireland

asked on

Application defined or Object error 1004

Hi,

I am getting the above error message on the below code, can anyone suggest a workaround?

Thanks
Seamus
Sub Combine()

'

Dim NumSheets As Integer

Dim NumRows As Integer

 

' Change the value of NumSheets to equal the number of sheets you wish to combine

 

NumSheets = 10

' Change the value of NumRows to equal the number of rows in each sheet

 

NumRows = 500

Worksheets(12).Select

Sheets.Add

ActiveSheet.Name = "Consolidated"

For X = 1 To NumSheets

Worksheets(X + 1).Select

Rows("2:" & NumRows).Select

Selection.Copy

Worksheets("Consolidated").Select

ActiveSheet.Paste

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Select

Worksheets(X + 2).Select

Range("A1").Select

Next X

Worksheets("Consolidated").Select

Range("A1").Select

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of etech0
etech0
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seamus2626

ASKER

Debugging on line

ActiveCell.Offset(1, 0).Select

Thanks
Which cell is selected when the macro stops running with the error message?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question was a favour for a friend who wouldnt provide the data behind it, so im going to close it off

Thanks for all your help