Unable to Assign Macro to Button

atclaeys

New Member
Joined
Sep 20, 2011
Messages
7
I keep getting an error saying that 'The formula you typed contains an error' when trying to assign the macro to a button. The macro works when I run it from the editor, regardless of which sheet I have open.

I was getting range select issues earlier so I know I'm activating sheets more than needed most likely but here's the code:

Code:
Sub R8_R12_Temp()
Worksheets("Main").Activate
Worksheets("Main").Range("D15").Copy
Worksheets("Plots").Activate
Worksheets("Plots").Range("F1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, Skipblanks _
     :=False, Transpose:=False
Worksheets("Main").Activate
Worksheets("Main").Range("D20").Copy
Worksheets("Plots").Activate
Worksheets("Plots").Range("H1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, Skipblanks _
     :=False, Transpose:=False
Worksheets("Main").Activate
End Sub

Any ideas why it won't let me assign this macro to a button?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Excel doesn't like that sub name for some reason. Try renaming it to


Sub MyR8R12Temp()
 
Upvote 0
Using a macro name beginning with an R and a number is like using a reserved name. Excel thinks you are trying to assign a Row number.
Change the name like VoG suggests and it will assign to your button.
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,914
Members
452,949
Latest member
beartooth91

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