VBA code doesn't work on sheet I have coded

kitsa

Board Regular
Joined
Mar 4, 2016
Messages
124
Office Version
  1. 365
  2. 2016
Hi Experts,
I have created a commend button in "Sheet1" to action spreadsheet in "Sheet2", but when I run the VBA code, it takes me to "Sheet2" on (Worksheets("Summary").Select), then the next part of the code it run's in "Sheet1". how does this happen and how do I fix this? I'm confused.

VBA Code:
Private Sub SummaryCopy_Click()

Worksheets("Summary").Select
Range("C7:S7").CurrentRegion.Copy
Range("C8:S8").PasteSpecial xlPasteFormulasAndNumberFormats

End Sub
 

Attachments

  • Sheet1 command tab.PNG
    Sheet1 command tab.PNG
    46.3 KB · Views: 4
  • Sheet2 VBA to action.PNG
    Sheet2 VBA to action.PNG
    72 KB · Views: 3
Glad you've got it sorted. thanks for letting us know.
 
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.

Forum statistics

Threads
1,226,453
Messages
6,191,135
Members
453,642
Latest member
jefals

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