Copy and paste

abac1

Board Regular
Joined
Feb 7, 2019
Messages
90
Hi
I’ve a worksheet called abc 1, abc 2 abc 3 and so on until abc 30. I’d like to have a command button in each sheet and when clicked then excel automatically copy row d5:d10 into a5:a10 and copy e5:e10 into c5:c10 into the new sheet from the previous sheet sequentially.

Pls can someone help me.

thanks
 

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.
Try it out.
VBA Code:
Sub SendToNewSheet()
    Dim sh As Worksheet, ws As Worksheet
    Dim Rng1 As Range, Rng2 As Range
    Dim nRng1 As Range, nRng2 As Range

    Set sh = ActiveSheet
    With sh
        Set Rng1 = .Range("D5:D10")
        Set Rng2 = .Range("E5:E10")
    End With

    Set ws = Sheets.Add(After:=Sheets(Sheets.Count))
    'ws.Name="SheetName" 'name sheet if required.
    With ws
        Set nRng1 = .Range("A5:A10")
        Set nRng2 = .Range("C5:C10")
    End With

    nRng1.Value = Rng1.Value
    nRng2.Value = Rng2.Value


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,194
Members
449,072
Latest member
DW Draft

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