Toggle Button to Format Cells

tenghensen

New Member
Joined
Jul 24, 2014
Messages
1
Hi All,

I am trying to code a toggle button to format a block of cells. Because I can only hide entire rows or columns, I am trying to just format the block of cells as ;;; so that the contents are hidden instead. If anyone can give me some code to do this, and show how to specify the cells that I want to format exactly, that would be really helpful.

Thanks
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Give this macro a try...
Code:
Sub ToggleCellVisibility()
  Dim RangeToToggle As Range
  Set RangeToToggle = [COLOR=#0000FF][B]Range("C3:F6")[/B][/COLOR]
  If RangeToToggle.NumberFormat = ";;;" Then
    RangeToToggle.NumberFormat = "General"
  Else
    RangeToToggle.NumberFormat = ";;;"
  End If
End Sub
Set your range in the highlighted section.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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