View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default CommandButton color change on event

Hi Peter,

Try something like:

'===============
Private Sub Worksheet_Change(ByVal Target As Range)
Const sAdd As String = "A1" '<<==== CHANGE

If Not Intersect(Range(sAdd), Target) Is Nothing Then
With Me.CommandButton1
If IsEmpty(Target) Then
.BackColor = &HFFFF&
Else
.BackColor = &HFF&
End If
End With
End If

End Sub
'<<===============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



"peter.thompson"
wrote in
message news:peter.thompson.204ivb_1134721202.472@excelfor um-nospam.com...

I want a CommandButton to change its backcolor when the content of a
worksheet cell is empty, and vice versa. Is this possible? Am new to
this stuff & would appreciate any help, ideas etc:


Cheers

Peter


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile:
http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=494066