Basic copy and paste macro

jjlang22

New Member
Joined
Nov 25, 2009
Messages
9
Hi, hopefully someone can help.

I have a 2 sheet spreadsheet.

The first sheet is an input sheet, with cells A2-5 all required entry fields.

The next sheet is a replica, but will hold all entries.

How do i write a macro which copys the data from sheet 1 into the next availabe blank row in sheet 2?
I have no experience of macro writing so would like to know all the steps from please.

Thanks
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

jjlang22

New Member
Joined
Nov 25, 2009
Messages
9
i made a mistake in my first post.

The input sheet has cells A1-E1 which need populated and the 2nd sheet replicates these
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hello and welcome to MrExcel.

Press ALT + F11 to open the Visual Basic Editor, select Module from the Insert Menu and paste into the white space on the right.

Code:
Sub Cpy()
Sheets("Sheet1").Range("A1:E1").Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub
Press ALT + Q to close the code window, Tools > Macro > Macros, click on Cpy then click the Run button.
 

jjlang22

New Member
Joined
Nov 25, 2009
Messages
9
Hi VoG

Thanks for the reply, that's ideal.

Now I just need to work out how to delete the input sheet so it's blank for the next user, and I'm ready to go.
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650

ADVERTISEMENT

That should be straightforward:

Rich (BB code):
Sub Cpy()
Sheets("Sheet1").Range("A1:E1").Cut Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub
 

jjlang22

New Member
Joined
Nov 25, 2009
Messages
9
Thanks for all your help on this.

One last question hopefully.

How do i change the code so I paste values?

I want to include a concatenate function in the input sheet but want the macro to copy and paste as a value in the 2nd sheet.

Thanks
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub Cpy()
With Sheets("Sheet1").Range("A1:E1")
    .Copy
    Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    .ClearContents
End With
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,556
Messages
5,596,820
Members
414,104
Latest member
imamalidadashzada

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