# Excel Formulas Help

Occasional Visitor

# Excel Formulas Help

I was wondering if there is a set of formulas for stock checking. I want to scan the code of a product and automatically highlight the product code in the excel table. It takes ages to Ctrl+F, scan the product, go color the cell then delete the code and repeat.

# Re: Excel Formulas Help

``````Sub color()

Dim i As Long

Range("A2:A1048576").Interior.ColorIndex = xlNone

For i = 2 To 26

If Cells(i, 1).Value = "AAAA" Then
Cells(i, 1).Interior.ColorIndex = 11
Else
If Cells(i, 1).Value = "BBBB" Then
Cells(i, 1).Interior.ColorIndex = 3

Else
If Cells(i, 1).Value = "CCCC" Then
Cells(i, 1).Interior.ColorIndex = 4
Else
If Cells(i, 1).Value = "DDDD" Then
Cells(i, 1).Interior.ColorIndex = 5
Else
If Cells(i, 1).Value = "EEEE" Then
Cells(i, 1).Interior.ColorIndex = 6
Else
If Cells(i, 1).Value = "FFFF" Then
Cells(i, 1).Interior.ColorIndex = 7

Else
If Cells(i, 1).Value = "GGGG" Then
Cells(i, 1).Interior.ColorIndex = 8

Else
If Cells(i, 1).Value = "HHHH" Then
Cells(i, 1).Interior.ColorIndex = 9

Else
If Cells(i, 1).Value = "IIII" Then
Cells(i, 1).Interior.ColorIndex = 10

End If

End If

End If
End If

End If

End If
End If

End If

End If

Next i

End Sub``````

Maybe this is similar to what you want to do. In the attached file you can click the button in cell E2 to run the macro. In the example the assumption is that the product codes are "AAAA", "BBBB", "CCCC" and so on.