Need to use color as argument excel

Closed
karissao - Aug 26, 2009 at 12:01 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Aug 26, 2009 at 07:25 AM
Hello,
I am writing a macro to produce payroll and have run into a snag. I pay a different amount for product x if the cell color is red than any other color. I need to put a logic test into the TOTAL column which will basically be "if cell color is red, 200, else 150" I do have visual basic but not sure if I can do this without it and need detailed instructions.

Thanks so much!
Related:

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Aug 26, 2009 at 07:25 AM
if the data is from A1 down in column A use this macro. modify the macro to suit you.

Sub test1()
Dim rng As Range, c As Range
Set rng = Range(Range("A1"), Range("A1").End(xlDown))
For Each c In rng
If c.Interior.ColorIndex = 3 Then
'colorindex=3 means red
c = 200
Else
c = 150
End If
Next c
End Sub
0