Add copy a new row

tobyhutton1234

New Member
Joined
Dec 21, 2010
Messages
24
Hi there,

I'm having a little trouble and looking for some assistance.

Basically on the top of my worksheet I have a button 'Add Record'. Once clicked I want the spreadsheet to copy the contents of lets say B7:Q7 (including borders and cell colours.) from one worksheet (Sheet 2) to another (Sheet 1).

Once the button is clicked it should be placed at B8:Q8 (from Sheet 2 to Sheet 1) and so on.

Does anyone how to go about doing this?

Thanks
 
What the code is doing is, is copying and pasting 3 line 3 B7, B6 and B5

Once the button is clicked again, after the line have copied the Debug launches and 'ActiveSheet.Paste' is highlighted yellow.
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
What the code is doing is, is copying and pasting 3 line 3 B7, B6 and B5

Once the button is clicked again, after the line have copied the Debug launches and 'ActiveSheet.Paste' is highlighted yellow.

Maybe:

Code:
Dim lr As Long

lr = Cells(Rows.Count, 2).End(xlUp).Row

    Sheets("DftRowSet").Select
        Range("B7:Q7").Copy
    Sheets("New Record").Select
        Range("B8").Offset(lr + 1).Select
    ActiveSheet.Paste
 
Upvote 0
No that doesnt seem to be doing it.

It copys into B7 from (DftRowSet) as normal then it's copying from B7 (New Record) to Range B13 (New Record) and then just copies as normal to B7
 
Upvote 0
No that doesnt seem to be doing it.

It copys into B7 from (DftRowSet) as normal then it's copying from B7 (New Record) to Range B13 (New Record) and then just copies as normal to B7

Sorry, I'm still trying to come up with something. However:

If Sheets("New Record") has a value in B6 then

the code below should do it?

Else

I'll keep trying

End if

Code:
Dim lr As Long

lr = Cells(Rows.Count, 2).End(xlUp).Row

    Sheets("Sheet1").Select
        Range("B7:Q7").Copy
    Sheets("Sheet2").Select
        Range("B" & lr + 1).Select
    ActiveSheet.Paste
 
Upvote 0
Sorry, I'm still trying to come up with something. However:

If Sheets("New Record") has a value in B6 then

the code below should do it?

Else

I'll keep trying

End if

Code:
Dim lr As Long

lr = Cells(Rows.Count, 2).End(xlUp).Row

    Sheets("Sheet1").Select
        Range("B7:Q7").Copy
    Sheets("Sheet2").Select
        Range("B" & lr + 1).Select
    ActiveSheet.Paste

Uh Oh. I missed your sample - in the code above you need to change Sheet1 to Sheet2 and vice versa.

Also, I notice your first code works as well. It works only if you add data and then click the button.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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