Try this.. this code will work without a button.. put the code in the sheet module..
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Low As Double
Dim High As Double
Low = 26 '< change as desired
High = 47 '< change as desired
'If the target cell is clear
If Target.EntireRow.Interior.ColorIndex = xlNone Then
'Then change the background to a random color
Target.EntireRow.Interior.ColorIndex = Int((High - Low + 1) * Rnd() + Low)
'But if the target cell is already the color
ElseIf Target.EntireRow.Interior.ColorIndex <> xlNone Then
'Then clear the background color
Target.EntireRow.Interior.ColorIndex = xlNone
End If
End Sub
Bookmarks