Append data from one worksheet to a another worksheet

maxebi

New Member
Joined
Sep 10, 2008
Messages
26
Hi,
I would like to append data from one worksheet (Append to Master) to another worksheet (Master).

Append to Master (data)

columns
A............B............C

abc........1234......aidan
def.........5678......aidan
ghi..........9012.....aidan



Master (data)
columns

A.............B..............C

mos........8765.........lang
mos........4321.........lang
mos........9876.........lang


Results would look like:

Master
columns

A............B............C

abc........1234......aidan
def.........5678......aidan
ghi..........9012.....aidan
mos........8765......lang
mos........4321......lang
mos........9876.......lang

Thanks for your help..

Ariano
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

ColinKJ

Well-known Member
Joined
Jan 27, 2009
Messages
983
Hi maxebi,

You could try something like this:

Code:
Sub CopyOver()
R = Workbooks("Data").Sheets("Data").Range("A65536").End(xlUp).Row
Workbooks("Master").Sheets("Master").Activate
For a = 2 To R
Cells(2, 1).Select
Selection.EntireRow.Insert
For x = 1 To 3
Cells(2, x) = Workbooks("Data").Sheets("Data").Cells(a, x)
Next x
Next a
End Sub

Regards

ColinKJ
 
Upvote 0

maxebi

New Member
Joined
Sep 10, 2008
Messages
26
Hi,
Thanks for the reply, but I receive 'subscript out of range' when I run this as a macro in both worksheets.
Do I run this as a macro? If so, from worksheet master or data? Or how do I run this?

Thank you for all your help.
Ariano
 
Upvote 0

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
This macro code will do what you are asking:
Code:
Sub Copy2Master()
'Assign variables for last row numbers in Source and Target worksheets
    lr = Sheets("Master").Range("A65536").End(xlUp).Row + 1
    ls = Sheets("Append to Master").Range("A65536").End(xlUp).Row
'Get range from "Append to Master" and copy
    Set Rng2 = Sheets("Append to Master").UsedRange.Offset(1, 0).Resize(ls - 1, 3)
    Rng2.Copy Sheets("Master").Range("A" & lr)
End Sub
As written, the code assumes you have a header row on the "Append to Master" worksheet that you do not want copied.
If you do not have a header row, change the "Set Rng2" line to this:
Code:
Set Rng2 = Sheets("Append to Master").UsedRange

You can run the code from either worksheet, it does not matter which is active.
 
Upvote 0

Forum statistics

Threads
1,191,686
Messages
5,988,068
Members
440,125
Latest member
vincentchu2369

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
Top