An If Statement based on colour?

aiden1983

Board Regular
Joined
Feb 19, 2009
Messages
120
I haven't tried it yet but is it possible to do an if statement based on colour? I want it to do a specific calculation in the colour is red and a diff one if it is blue etc. ie If the cell is red and the number 5 is in it then do x=10-5 if the cells is blue and the number 5 is in it then do x=20-5 etc. Is this possible?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If the cells are coloured manually then you would need VBA code to do this.
 
Upvote 0
Perhaps:
How is the cell colored? Manually or with Conditional Formatting?
lenze
 
Upvote 0
It's definitely easier with VBA or if the cells are colored via conditional formatting, but it's possible with manual shading and no VBA.

You'd need to use GET.CELL though as outlined here: http://www.mrexcel.com/forum/showthread.php?t=20611

Or, more specifically, =GET.CELL(38,OFFSET(INDIRECT("rc",FALSE),0,1)) or similar in a named range
 
Upvote 0
oh yes they are coloured manually and I will be using vba. Thanks for the help I will check out those links.

Aiden
 
Upvote 0
Maybe something as simple as
Code:
Sub Fanugi()
Dim cl as Range
For Each cl in Range("$A$2:$A" & Range("$A$65536").End(xlUp).Row)
Select Case cl.Interior.ColorIndex
      Case 3 : Cells(cl.Row,2) = 10 - cl
      Case 5 : Cells(cl.Row,2) = 20 - cl
      'etc
      Case Else:
End Select
Next cl
End Sub
lenze
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,287
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top