Button Help

Status
Not open for further replies.

young engineer

Board Regular
Joined
Mar 3, 2009
Messages
100
Hi All
I need to programme a button to show the following columns side by side
F:S, I:V, M:Z, Q:AD, AH:AK. When the button is not selected then the columns should return back to their normal positions. Is it possible to to also have columns F,I,M,Q in one colour and columns S,V,Z,AD,AK in another colour.
How do i go about doing this. Please help
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I need to programme a button to show the following columns side by side
F:S, I:V, M:Z, Q:AD, AH:AK.
That means you want to hide the other columns?

For example, with
Code:
Sub Hide()
    Columns("A:E").Hidden = True
End Sub

Sub Unhide()
    Columns("A:E").Hidden = False
End Sub
When the button is not selected...
This is not an event that you can work with.
One moment a button is pressed and less than a second later it is not pressed but what do you want?
You may need a second button for this...
 
Upvote 0
You can actually do this with a command button by also changing something in the button itself, like the Caption, and do an IF test on that value. Like this:
Code:
Private Sub CommandButton10_Click()
    If CommandButton10.Caption = "HIDE A:E" Then
        CommandButton10.Caption = "SHOW A:E"
        CommandButton10.ForeColor = &HFFFF&
        CommandButton1.ForeColor = &H808080
        Columns("A:E").Hidden = True
    Else: CommandButton10.Caption = "HIDE A:E"
        CommandButton10.ForeColor = &HC0&
        CommandButton1.ForeColor = &H800000
        Columns("A:E").Hidden = False
    End If
End Sub
This dynamically changes the color and the caption so one button does something different each time it is pressed.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

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