Button text

patnitin

New Member
Joined
Mar 23, 2006
Messages
27
Hi,
I have some buttons in my worksheet which hide and unhide some of the columns on clicking it.I want the text to alternate between signs '+' and '-',based on whether its hiding/unhiding the columns.Inother words I want the button text to shw '+' sign when the columns are to be expanded and sign'-' when the columns are to be hidden.Such kind of application I have seen in many sheets but unable to do it my self.(kindly note the I have wrtten the code for the columns to be hidden/unhide and I want only the button text to change)

Can anybody help!
Thanks in advance.

Regards,
Nitin
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,764
Have you tried the macro recorder? This is what it produces for me

Code:
ActiveSheet.Shapes("Button 1").Select
    Selection.Characters.Text = "Hello"
    With Selection.Characters(Start:=1, Length:=5).Font
        .Name = "NewsGoth BT"
        .FontStyle = "Roman"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
End Sub

Obviously, a lot of the erroneous code could be removed.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,993
Messages
5,545,377
Members
410,679
Latest member
rolandbianco
Top