Macro to copy and paste in new line.

seriousdamage

Board Regular
Joined
Aug 14, 2005
Messages
58
Hi, I have recorded the below macro, to copy some cells and paste them in a different sheet,
unfortunately every time I run the macro, it keeps copying in the same spot and overwrites what was there before instead of searching for the next available row.

Can anyone help?
Thanks
Nic
Code:
Sub enterdata()
'
' enterdata Macro
' Macro recorded 9/22/2006 by Cisco Systems, Inc.
'

'
    Sheets("Form").Select
    Range("A7:D7").Select
    Selection.Copy
    Sheets("Database").Select
    ActiveCell.SpecialCells(xlLastCell).Select
    Range("A2").Select
    ActiveSheet.Paste
    Range("E2").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(Database!RC[-2],Information!C[-4]:C[-3],2,0)"
    Range("F2").Select
    ActiveCell.FormulaR1C1 = "=RC[-5]+RC[-4]"
    Range("F3").Select
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
Code:
    Worksheets("Form").Range("A7:D7").Copy
    Sheets("Database").Activate
    LR = ActiveCell.SpecialCells(xlLastCell).Address
    Range(LR).PasteSpecial Paste:=xlAll, Operation:=xlNone
    Range("E2").FormulaR1C1 = _
        "=VLOOKUP(Database!RC[-2],Information!C[-4]:C[-3],2,0)"
    Range("F2").FormulaR1C1 = "=RC[-5]+RC[-4]"

probably will still need some tweeking
 

seriousdamage

Board Regular
Joined
Aug 14, 2005
Messages
58
Unfortunately it does not work 100%, now it copies the data from the last cell with data, instead of from the cell A1 of the next free row.

Any more ideas?

Thanks
Nic
 

Forum statistics

Threads
1,140,941
Messages
5,703,292
Members
421,290
Latest member
java

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