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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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