Run-time error 1004 in macro for merging data across tabs

Rajni

New Member
Joined
Aug 18, 2011
Messages
7
HI

I'm trying to merge data from 3 tabs into a new tab. For the first two tabs
it is correctly copying rows and pasting in new tab (alldefects) but for tab3 it is giving this error.

While debugging I could see that its selecting huge no. of rows instead of
only single row (as Tab3 has only 1 row for now).

Error is >>
Run-time error '1004'
The information cannot be pasted because the Copy area and the Paste area are
not the sa,e size and shape. Try one of the following.
** Click a single cell, and then paste.
** Select a rectangle that's the sa,e size and shape, and then paste.

Code for Tab3 (similar code is used for all three tabs) is >>
Query3sheet.Activate
' check if data is there to copy
if ActiveSheet.Range("A2") <> "" then
'select all rows with data till end
ActiveSheet.Range("A2").Select
ActiveSheet.Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select
Selection.copy
AllDefectssheet.Activate
'get the last cell in this tab and paste....
LastCell = ActiveCell.SpecialCells(xlLastCell).Row
Range("A" + Trim(Str(LastCell+1))).Select
Activesheet.paste ' Error coming here.....
end if
 
This is the code to identify the used last row if it is any blank any blank between the rows.
Last_Row = ActiveSheet.UsedRange.Rows.Count
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,584
Messages
6,179,687
Members
452,938
Latest member
babeneker

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