0
Thanks

A few words of thanks would be greatly appreciated.

# Button to color certain numbers in excel sheet

## Issue

I'm looking for a way to make a button color all numbers equal to the number on the button... as an example, let's say i have a row of buttons from 1 to 10, and in the same sheet cells with numbers from 1 to 10 in no order. I now want quickly to be able identify all 3's and 7's by color. "Simple: click button 3, action: color all cells with the number 3 in it and let it be like that until i press the button again...

## Solution

I shall give another solution print these instructions and follow (provided it suits you)

OPEN A NEW EXCEL FILE

now in vb editor copy this macro

```Sub test()
Dim x As Integer, cfind() As Range, j As Integer, k As Integer, add As String
Columns("A:A").Interior.ColorIndex = xlNone

x = Range("F1").Value
j = WorksheetFunction.CountIf(Columns("A:A"), x)
If j = 0 Then
MsgBox "no such value is available in column A"
Exit Sub
End If
ReDim cfind(1 To j)

For k = 1 To j
Set cfind(k) = Columns("A:A").Cells.Find(what:=x, lookat:=xlWhole)
cfind(k).Interior.ColorIndex = 3

Do
Set cfind(k) = Columns("A:A").Cells.FindNext(cfind(k))
If cfind(k) Is Nothing Then Exit Do
cfind(k).Interior.ColorIndex = 3
Loop
Next k

End Sub
```

in the list of form toolbars there is one called spinner
click it and draw a spinner button
right click the button and click "format control"
in that window choose control (the last item in the top row)
type 1 against "minimum value"
type 10 against "maximum value"
"incremental change" will be 1
click ok

again right click the spinner button and click "assign macro" the name "test " will come up. highlight that and click ok suppose the numbers are in column A to test type some integers between1 and 10(some repeating twice or thrice, some numbers missing )from A1 to A20 save the file now select any cell outside the spinner button and again click upward or downward arrow in the spinner button. See the value in F1. if F1 is 1 nothing will happen if you click downward arrow similarly if F1 is 10 upward arrow will not give anything otherwise go on clicking the downward or upward arrows, keep watch in F1 and see those numbers(whose value is F1 value) in column A will be marked red. Will this of use to you. You can modify the plan

## Note

Solved by venkat1926

0
Thanks

A few words of thanks would be greatly appreciated.