Need to use color as argument excel

[Closed]
Report
-
Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
-
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!

1 reply

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
800
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

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!