Highlighting Boxes if a column width =0

Jaywar2013

New Member
Joined
Apr 5, 2013
Messages
23
Hi All

I have some simple Open/Close text macro buttons which reduce the column width to 0 when pressed, then when another is pressed it sets it to the desired width.

I have been asked if it is possible to highlight something to tell the user which are set to 0 (Highlighted Red) and which are set to the normal width (Highlighted green)

I would be good if it was the label text that changed colour in the text boxes if possible.

Your hopefully

Jay

:confused:
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
How do I do that?

The macros are:
Code:
Sub Close1()
'
' Close1 Macro
'


'
    Columns("G:G").Select
    Selection.EntireColumn.Hidden = True
    Range("A1").Select
End Sub

Sub Open1()
'
' Open1 Macro
'


'


'
    Columns("G:G").Select
    Selection.EntireColumn.Hidden = False
    Range("A1").Select


'
End Sub
button 1 = Open
button 2 = close

there is a text box which can be any title

Column G has the header and text
 
Last edited by a moderator:
Upvote 0
I would like

If column G = 0 width then Textbox1 = Red text (Or box), if column G = 40 width then textbox1 = green text (Or box)
 
Upvote 0
You could just use one button with the following macro assigned - the button text and font colour will change each time it's clicked as it toggles the column's visibility:
Code:
Sub ShowHide()
   Columns("G:G").Hidden = Not Columns("G:G").Hidden
   With ActiveSheet.Buttons(Application.Caller)
      If Columns("G:G").Hidden Then
         .Caption = "Open"
         .Font.Color = vbGreen
      Else
         .Caption = "Close"
         .Font.Color = vbRed
      End If
   End With
End Sub
 
Upvote 0
Cheers for looking at this for me Rory

I am very very new to Macros and VBA

I get a debug on the below line, Do I need to change this to Oval 1?

With ActiveSheet.Buttons(Application.Caller)
 
Upvote 0
If you are using Ovals rather than buttons, then replace
Code:
With ActiveSheet.Buttons(Application.Caller)
with:
Code:
With ActiveSheet.Ovals(Application.Caller)
;)
 
Upvote 0
Brilliant Cheers Mate

Is there a way I can do the text white and the oval fill red and green too?

I love this site :cool:
 
Upvote 0
Sure:
Code:
Sub ShowHide()
   Columns("G:G").Hidden = Not Columns("G:G").Hidden
   With ActiveSheet.Ovals(Application.Caller)
      .Font.Color = vbWhite
      If Columns("G:G").Hidden Then
         .Caption = "Open"
         .Interior.Color = vbRed
      Else
         .Caption = "Close"
         .Interior.Color = vbGreen
      End If
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,483
Messages
6,113,919
Members
448,533
Latest member
thietbibeboiwasaco

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