Runtime Error 1004

cristovam4

New Member
Joined
Apr 5, 2015
Messages
2
Hi Friends,


I´ve searching all across Google but haven´t found a solution yet. :geek:
I have a workbook with a number of sheets (my projects). They increase and decrease based on my business demands.
I´m trying to consolidate 1 column of data for each sheet in one single sheet, in the same column, one after another.
When i run the macro I get the error 1004. What I´m doing wrong?

Code:
[COLOR=#2E8B57][FONT=Monaco]Sub test1()[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Dim ws As Worksheet[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]For Each ws In Worksheets[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]If ws.Name <> "Dashboard" Then[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]ws.Select[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]ws.Application.Run "consolidate"[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]End If[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Next[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]End Sub[/FONT][/COLOR]

[COLOR=#2E8B57][FONT=Monaco]Sub consolidate()[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Range(Range("H2"), Range("H2").End(xlDown)).Select[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Selection.Copy[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Sheets("Dashboard").Select[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Range("A1048576").End(xlUp).Offset(1, 0).Select[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Selection.PasteSpecial[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]Application.CutCopyMode = False[/FONT][/COLOR]
[COLOR=#2E8B57][FONT=Monaco]End Sub[/FONT][/COLOR]
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try this...

Code:
[color=darkblue]Sub[/color] test1()
    [color=darkblue]Dim[/color] ws     [color=darkblue]As[/color] Worksheet
    [color=darkblue]For[/color] [color=darkblue]Each[/color] ws [color=darkblue]In[/color] Worksheets
        [color=darkblue]If[/color] ws.Name <> "Dashboard" [color=darkblue]Then[/color]
            ws.Range("H2", ws.Range("H" & Rows.Count).End(xlUp)).Copy
            Sheets("Dashboard").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]Next[/color]
    Application.CutCopyMode = [color=darkblue]False[/color]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Worked as a charm!
Very, very thanks AlphaFrog.

Try this...

Code:
[COLOR=darkblue]Sub[/COLOR] test1()
    [COLOR=darkblue]Dim[/COLOR] ws     [COLOR=darkblue]As[/COLOR] Worksheet
    [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] ws [COLOR=darkblue]In[/COLOR] Worksheets
        [COLOR=darkblue]If[/COLOR] ws.Name <> "Dashboard" [COLOR=darkblue]Then[/COLOR]
            ws.Range("H2", ws.Range("H" & Rows.Count).End(xlUp)).Copy
            Sheets("Dashboard").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]Next[/COLOR]
    Application.CutCopyMode = [COLOR=darkblue]False[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,697
Members
449,331
Latest member
smckenzie2016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top