Copy and Paste range into another tab

Animalised

New Member
Joined
Apr 24, 2016
Messages
31
Good Evening,

I'm trying to find a cell range, copy the information from that range and paste it into another tab. This is my code so far:

Code:
Private Sub CommandButton1_Click()
    Sheets("Summary").Select
    ' Find "C4" cell of data
        If ThisValue = "PB" Then
            Range(Cells(4, 2), Cells(4, 8)).Copy
            Sheets("Peter Beardsall").Select
            Cells(4, 2).Select
            ActiveCell.EntireRow.Insert
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("Summary").Select
        ElseIf ThisValue = "ND" Then
            Range(Cells(4, 2), Cells(4, 8)).Copy
            Sheets("Nick Dyson").Select
            Cells(4, 2).Select
            ActiveCell.EntireRow.Insert
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
            Sheets("Summary").Select
        End If
End Sub



I'm not sure what I could do to make it work as nothing seems to happen.


Any help would be greatly appreciated!
 
Using this code:

Code:
[COLOR=#00008B][FONT=Verdana]Sub CommandButton1_Click()[/FONT][/COLOR]
[COLOR=darkblue]    Dim[/COLOR] ThisValue [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
    Sheets("Summary").Select
    [COLOR=green]' Find "C4" cell of data[/COLOR]
    ThisValue = Cells(4, "C").Value
    [COLOR=darkblue]If[/COLOR] ThisValue = "PB" [COLOR=darkblue]Then[/COLOR]
        Range(Cells(4, 2), Cells(4, 8)).Copy
        Sheets("Peter Beardsall").Cells(4, 2).EntireRow.Insert
        [COLOR=green]'            Cells(NextRow, 1).Select[/COLOR]
        [COLOR=green]'            ActiveSheet.Paste[/COLOR]
        Sheets("Summary").Select
    [COLOR=darkblue]ElseIf[/COLOR] ThisValue = "ND" [COLOR=darkblue]Then[/COLOR]
        Range(Cells(4, 2), Cells(4, 8)).Copy
        Sheets("Nick Dyson").Cells(4, 2).EntireRow.Insert
        [COLOR=green]'            Cells(NextRow, 1).Select[/COLOR]
        [COLOR=green]'            ActiveSheet.Paste[/COLOR]
        Sheets("Summary").Select
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    Application.CutCopyMode = [COLOR=darkblue]False[/COLOR] 
End Sub

I changed "Sheets("Peter Beardsall").Cells(4, 2)" in the following area:

Code:
    If ThisValue = "PB1" Then
        Range(Cells(4, 2), Cells(4, 8)).Copy
        Sheets("Peter Beardsall").Cells(4, 2).EntireRow.Insert
        '            Cells(NextRow, 1).Select
        '            ActiveSheet.Paste
        Sheets("Summary").Select

Into "Sheets("Peter Beardsall").Cells(6, 2)", so a row wasn't inserted at "Cells(4, 2)" and instead at "Cells(6, 2)", which allowed for me to format the area above for sum totals:

Code:
    If ThisValue = "PB1" Then
        Range(Cells(4, 2), Cells(4, 8)).Copy
        Sheets("Peter Beardsall").Cells(6, 2).EntireRow.Insert
        '            Cells(NextRow, 1).Select
        '            ActiveSheet.Paste
        Sheets("Summary").Select


Again, thankyou!
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Ok, so the NextRow and the quote below from your other thread are not applicable, all you needed was the fixed cell. All good. :biggrin:

in a way that doesn't delete the previous pasted entry.
When the data has been copied over,
 
Last edited:
Upvote 0
Hi Mark,

It worked perfectly, thankyou very much for your help!

I've copied the IF statement to apply to all persons mentioned in the document (12 persons mentioned in total). I may try to use your shorter version to simplify this code.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

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