Hi
I would like to change the color of a set of commands buttons based in a cell value Fail(red) Pass(green)
I have a main sheet with all the commandbuttos (one for each Item) in the real sheet I have more than 3 items that is the reason I would like to create something like the followint code
then for each Item I have a sheet and in each sheet has a validation cell to choose pass or fail.
But I get an error every time that the main sheet is activate and call the IpdateItemStatus sub
Any help?
Many thanks
Sub UpdateItemStatus()
Dim Itemname(3) As String
Dim i
Dim ItemSheetName As String
Dim ButtonName As CommandButton
Itemname(1) = "A1"
Itemname(2) = "A2"
Itemname(3) = "A3"
For i = 1 To 3
SheetName = Itemname(i)
With ButtonName
'I get an error here run time erro 91 Object variable or With Block variable not set
.Caption = "btn_" + Itemname(1)
End With
If Sheets(ItemSheetName).Range("D5") = "Fail" Then
Sheets(MainSheet).ButtonName.BackColor = &H8000000F 'Red Color
Else
Sheets(MainSheet).ButtonName.BackColor = &HFF00& 'Green color
End If
End sub
Bookmarks