Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Changing the colour of a control button in Excel

What VB script is needed to, say, change the colour of a control button say
from gray to red when it is clicked.

I've tried using the scripts given in:

http://www.mrexcel.com/archive/Controls/5034.html

but nothing is happening when the button is clicked - if I format it as grey
and click it, then it stays gray, if I format it as red and click it, it
stays red. I would like it to change to red when clicked and remain gray
when not clicked - it must be possible!

many thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Changing the colour of a control button in Excel

In the Click event for your button, you can include code like this:

If CommandButton1.BackColor = vbRed Then
CommandButton1.BackColor = vbButtonFace
Else
CommandButton1.BackColor = vbRed
End If

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Changing the colour of a control button in Excel

Jeff,

many thanks!

" wrote:

In the Click event for your button, you can include code like this:

If CommandButton1.BackColor = vbRed Then
CommandButton1.BackColor = vbButtonFace
Else
CommandButton1.BackColor = vbRed
End If


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Changing the colour of a control button in Excel

I'm not quite sure what you want to do, perhaps this -

Private Sub CommandButton1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

CommandButton1.BackColor = vbRed
End Sub

Private Sub CommandButton1_MouseUp(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

CommandButton1.BackColor = vbButtonFace
End Sub

You might need similar KeyDown & KeyUp events. Normal code can go in either
the Down or Up events. Hope you'll choose a less forcefull colour than Red.

Regards,
Peter T

"Zakynthos" wrote in message
...
What VB script is needed to, say, change the colour of a control button

say
from gray to red when it is clicked.

I've tried using the scripts given in:

http://www.mrexcel.com/archive/Controls/5034.html

but nothing is happening when the button is clicked - if I format it as

grey
and click it, then it stays gray, if I format it as red and click it, it
stays red. I would like it to change to red when clicked and remain gray
when not clicked - it must be possible!

many thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Cell Link on Spin Button Form Control Adam Ronalds Excel Discussion (Misc queries) 14 August 27th 09 05:52 PM
Changing background colour when changing data in a cell Paoul Excel Discussion (Misc queries) 7 December 26th 08 07:25 AM
Changing all cells in one colour to a different colour Bob Excel Discussion (Misc queries) 3 June 25th 08 02:12 PM
changing button colour mamun316[_4_] Excel Programming 1 December 11th 05 05:25 AM
excel control button T F Hewitt[_2_] Excel Programming 0 October 29th 03 10:21 PM


All times are GMT +1. The time now is 02:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"