reference must be to a macro sheet

itlsbu

Board Regular
Joined
Jul 2, 2002
Messages
102
hello,

I have a simple macro (see below). When I try to assign it to a button, I get the message "reference must be to a macro sheet". Never had that before and even after searching for a hour I have no idea what I have done wrong or what it is I am missing.

Help would be appreciated

Sub EW1()
'

ActiveSheet.Unprotect
Columns("A:E").Select
Range("E1").Activate
Selection.EntireColumn.Hidden = False

End Sub

thanx steven
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,884
Hi Steven

Cell addresses are not valid names in the worksheet environment.

Try for example to use the macro recorder to create a macro named A1 or D4 (or EW3) and you'll get the error message "Name is not valid."

Rename the macro.

Hope this helps
PGC
 

itlsbu

Board Regular
Joined
Jul 2, 2002
Messages
102
PGC,

Thanx for the response, I did not know that, I will try it
In the meantime I copied the macro in a existing module and than it did work...

anyway thanx for the reply

steven
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,884
Hi again

In the meantime I copied the macro in a existing module and than it did work...

Yes, in a module there's no problem, you can have a macro called A1.

As I said the problem arises in the worksheet environment.

Kind regards
PGC
 

Forum statistics

Threads
1,136,268
Messages
5,674,734
Members
419,523
Latest member
Urnovio

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
Top