How to write the code for toggle button...stupid things

Status
Not open for further replies.

nadirv8

New Member
Joined
Sep 12, 2006
Messages
9
Hi All,

Having issues with a macro im trying to get working for a button. All it is: selecting multiple columns and hiding them. This is it (below) and VB is rejecting the range,... or any range for that matter.

Code:
Private Sub CommandButton1_Click()
    Sheets("Holland").Select
    Range("D:D,H:H,L:L,P:P,T:T,X:X,AB:AB,AF:AF,AJ:AJ,AN:AN,AR:AR,AV:AV").Select
    Range("AV1").Activate
    Selection.EntireColumn.Hidden = True
    Sheets("CONTROL").Select
    Range("D1").Select
End Sub

Anyone got ideas of why its not working on the button?

Thankyou very very much!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Good morning nadirv8

There is nothing wrong with the code per se. What sheet is the button placed on? You can have problems running code behind a button on Sheet A if it is selecting a range on Sheet B.

As a workaround you could put the code in a standard module and call it from your command button code.

HTH

DominicB
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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