Bringing me back to a sheet

ERed1

Board Regular
Joined
Jun 26, 2019
Messages
104
Hey all,

I have this copy and paste code for a button. Here is the code:
If Range("B16").Value = "Dog" Then
Sheets("Animals").Range("A16:D19").Copy
Sheets("Finished").Activate
lastrow = Range("A65536").End(xlUp).Row
Cells(lastrow + 5, 1).PasteSpecial Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Sheets("Animals").Range("A125:D130").Copy
Sheets("Finished").Activate
lastrow = Range("A65536").End(xlUp).Row
Cells(lastrow + 1, 1).PasteSpecial Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If


After it gets pasted, I get stuck on the finished page. Is there a way to bring me back to the "Animals" sheet? Thanks in advance.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Just add:
Code:
[COLOR=#333333]Sheets("Animals").Activate[/COLOR]
 
Upvote 0
Or don't activate the other sheet in the first place.:)
Code:
If Range("B16").Value = "Dog" Then

    With Sheets("Finished")

        Sheets("Animals").Range("A16:D19").Copy

        lastrow = .Range("A65536").End(xlUp).Row
        .Cells(lastrow + 5, 1).PasteSpecial Operation:=xlNone, SkipBlanks:=False, Transpose:=False

        Sheets("Animals").Range("A125:D130").Copy

        lastrow = Range("A65536").End(xlUp).Row
        .Cells(lastrow + 1, 1).PasteSpecial Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    End With

End If
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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