Hide Columns on multiple sheets based on option button

iSoleil

New Member
Joined
Oct 14, 2017
Messages
17
Hi guys,

My code to show/hide columns on multiple tabs does seem to work. I know it's very basic, but I just learned VBA codes from googling it and I can't seem to crack this one.

What I want to do is hide columns F:J on sheets 1-31 (same sheet names too) if OptionButton1 is clicked and show columns F:J if OptionButton2 is clicked.

This was my very mediocre attempt at testing it on Sheet1. Surprise, surprise. Not working.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If OptionButton1.Value = True Then
    Sheet1.Columns("F:G").Hidden = True
Else
    Sheet1.Columns("F:G").Hidden = False
End If
End Sub


Any help is greatly appreciated. Thanks!
 
Hi Alan,

I thought of going this route. I just replaced the sh.Name with 1 - 30, but it's not working.


Thank you for the attempt tho.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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