Color Code Values With Function
Mar 5, 2010
I have values that I want to color code in my table. Originally I was tagging them as numbers, but instead I need them as colors.
Function conversion(pVal As Double)
If pVal > 0.05 Then
conversion = "1"
ElseIf pVal > 0.001 Then
conversion = "2"
ElseIf pVal > 0.0001 Then
conversion = "3"
ElseIf pVal > 0.00001 Then
conversion = "4"
End If
End Function
Now I want instead of conversion = "1" etc to be
Function conversion(pVal As Double)
If pVal > 0.05 Then
(make white)
ElseIf pVal > 0.001 Then
(make brighter blue)
ElseIf pVal > 0.0001 Then
(make green)
ElseIf pVal > 0.00001 Then
(make navy blue)
End If
End Function
I want the text and cell the same color (number and cell so the number disappears so that I just have a colored cell but the value is still there if I want to look at it).
View 9 Replies
ADVERTISEMENT
Jan 9, 2008
Is it possible to use different text colours as part of the [Value_If_True] or [Value_If_False] when using an IF formula? For example =IF(AS3<34,"ok","not ok")
In the above formula I would like the “ok” value to be in Blue and the “not ok” value in Red.
View 2 Replies
View Related
Feb 15, 2010
I would like to be able to change the color of a cell in V4:AB31 and have the formula in AM10:AM13 automatically calculate the new result. As it is now the user has to press Ctrl ALT f9 for the formula to recalculate.
View 7 Replies
View Related
Apr 7, 2009
I am having a bit of a problem creating a formula for this report that I have to update every week. I need to be able to find the room nights and net room revenue values for the specific rate code in the "MATRIX" workbook.
On "CURRENT REPORT," I need D4 to pull up the value on "MATRIX" that equals "Room Nights" in column H and "CONABC" in column J. The same thing needs to happen for F4 but with "Net Room Revenue" in column H. The full report has about 500 of these codes in column J, and I need a formula that I can copy easily and will not be affected if codes are added or removed. This is super last minute - I need to finish this report by tomorrow morning, so take a look at the attachments.
View 2 Replies
View Related
Sep 5, 2006
I work for a training company based near Gatwick. We are currently producing a new course and one of the new functions we are using is the MOD function. We are using it to colour alternate lines (Conditional formatting). The formula works great, but we do have a few mathematical questions on it.
The formula is:
=MOD(Row()-C,N*2)+1<=N
The question I have is about the sections in red, why are they there and why do they make it work?
View 4 Replies
View Related
Dec 10, 2006
how to use an IF statement if the cell color is a certain color? Using conditional formatting, cell A1 is either blank, light yellow, or red. Now, if A1 is light yellow, I want the value in A1=3, if not then the value =5. The formula would look something like:
IF (A1 = light yellow, 3, 5)
View 9 Replies
View Related
Nov 11, 2009
I use the code below to automatically set a black dot in cell
A11. I would like to add code which would color that dot
the same color as a manually placed checkmark in column C11 which
is symbol é.
In other words, in addition to the code printed below, I would
like to color the dot the same color as the color of the arrow
symbol é in column C11.
Is that possible? Thanks
=IF(AND(B11="ü",D11="X"),CHAR(108)," ")
View 14 Replies
View Related
May 9, 2009
I'm trying to use Excel to keep team standings for a baseball board game. I had no problem calculating wining percentage. Finally figured out how to calculate 'games behind.' Now I'm wondering if there is a way to change the font color of a team name based on their wining pct?
A typical row contains: A2(Team Name), B2 (Wins), C2 (Losses), D2 (Pct (B2/(B2+C2)), E2 (GB). Is there a way to use the IF function to return the 'Team Name' in green if D2>.500, 'Team Name' in red if D2<.500, and 'Team Name' in black if D2=.500 ??
View 4 Replies
View Related
Sep 5, 2013
A brief rundown on what I am trying to create. My family and I have a NFL football game we do every year to see who can correctly guess the most winners over the course of the season and then the ultimate winner receives a prize at the end of the season. After years of doing this manually, I decided to try and put my Excel skills to use and create a more "automated" worksheet.
After some heavy research, I was able to successfully create a user defined VBA which would calculate a "win" every time a cell is highlighted (in my case the winning team's name). For example, I highlight New England Patriots and when the formula calculates each person receives 1 in their win column.
However, I have now reached a problem I failed to think of. The formula does not take into consideration the picks everyone is going to make. Not everyone is going to select the winning team, so the current formula I have is giving credit for every highlight. Is there a way to add an if statement to this? For example, if person A selected New England Patriots and it's highlighted then give 1, if not give 0?
I know it's usually hard to base a formula off a cell color.
For some reason, I cannot attach the spreadsheet I am currently using. For a brief overview, cell M1 contains the color which I would use to highlight the cells in the range A2:H17. This formula is in cells B21 - B27.
The VBA which I input was:
Function CountCcolor(range_data As range, criteria As range) As Long Dim datax As range Dim xcolor As Longxcolor = criteria.Interior.ColorIndexFor Each datax In range_data If datax.Interior.ColorIndex = xcolor Then CountCcolor = CountCcolor + 1 End IfNext dataxEnd Function
Where the picks which are made should be logged. Whether each person gets a separate color and the VBA is based on that, or like I alluded to above if there is an X here and it's highlighted or something.
View 1 Replies
View Related
Sep 22, 2009
I was wondering if there's a way to make the numbers in a column over 50 (as an example) green and numbers less than 50 red. (The numbers in this column are the sums of other cells, but I guess that doesn't really matter.)
This way when there's a lot of things going on you can see what's what without filtering or rearranging.
View 2 Replies
View Related
Jan 13, 2012
Is there a way to Print VBA code in color, like how it appears on the screen?
View 1 Replies
View Related
Jan 20, 2012
Is there VBA color to change ".Fill.ForeColor.SchemeColor =" into NO FILL? In other words, keeping the existing Foreground color prior to the macro being activated.
I'm in a chart.
View 1 Replies
View Related
Aug 21, 2007
I have a code that updates data from one file to another.....esentially, i run this code daily and it updates to a compiled daily log of all of the previous days data.
Currently, i am manually coloring the cells to visually assist in grouping what data has been uploaded for each day.
Sub UpdatePOQntyReducDB()
Dim lookupfilename As String
View 9 Replies
View Related
Nov 6, 2007
part of my code looks like this. Instead of it being if c.interior.colorindex i want it to be if top border color = 4.
How do i syntax this?
For Each c In Worksheets("Sheet1").Range("B7:DE7").Cells
If c.Interior.ColorIndex = 4 Then Range("DH7").Value = Range("DH7").Value + c.Value
Also, is there a way to specify Range("DH") and make the row be the current row, not hard coded to 7
View 9 Replies
View Related
Mar 18, 2009
I am using the following code to change colors in set of autoshapes (Thanks Colin_L and Norie) and it works fine for the first autoshape but has it has no effect on the subsequent autoshapes. I plan on using the code for about 200 autoshapes, I thought I could just copy the first code and keep adding it on for each autoshape... I am guessing that the code is stopping after the first set and not continuing?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$46" Then
'Change autoshape color to red depending upon cell value, or blank of no value is entered.
With ActiveSheet.Shapes("Rectangle 1").Fill.ForeColor
If Target.Value = "" Then
.SchemeColor = 1
ElseIf Target.Value >= 422 Then
.SchemeColor = 50
ElseIf Target.Value >= 1 Then
.SchemeColor = 10
Else
'it must be less than 1
End If
End With
End If......
View 9 Replies
View Related
Aug 12, 2009
Is it possible to have a code that says if I have a range of cells....say a1:d1 with d1 having a date in it....have that code say that if that date in d1 is greater than 30 days from today, make that whole range of cells (a1:d1) change color like to red.
View 9 Replies
View Related
Apr 10, 2012
If the percent in a cell is more than 10% less than another cell I would like it to turn red. I would like the cell to turn yellow if the percent in that cell is within 10% below the percent in another cell, or if the percent is greater than that of another cell I would like the cell to turn green. How do I do this?
To clarify; If cell a1 is 20% and Cell a2 is 21%, I would like the color in cell a1 to turn yellow since it is less than 10% below cell a2. OR if cell a1 is 25% I would like it to turn green since it is greater than cell a2. OR if cell a1 is 10% I would like it to turn red since it is more than 10% below cell a2.
I've looked at conditional formatting and it does not seem to apply, this seems like it would need an if function combined with conditional formatting.
View 3 Replies
View Related
Sep 16, 2012
Using Excel 2010 Pro.
I have a formula to create a string to create a lable for a Trial Balance report
=LEFT(I5&" "&REPT(".",95),101)
But the decimal portion of the string is distracting. I would like to make it a grey instaed of a black so that the text portion of the label "pops".
I don't believe I can do it with conditional formatting and I do not want to do it manually.I was thinking some kind of function or UDF like:
=LEFT(I5&" "&RGB(REPT(".",95),(191,191,191)),101)
View 3 Replies
View Related
Apr 20, 2006
I am not looking into a VBA solution for this one and want to keep it simple. I want to enter a basic IF function/formula to make the color of a cell yellow if the condition is true.
Here is where I am stuck/what I am putting inside the cell:
=If( 'Program Tracker'!E16="","",IF('Program Tracker'!E16>= DATE(2006,3,3),IF('Program Tracker'!E16<=(DATE(2006,3,9)),"YELLOW","")))
Where you see "YELLOW" is where I need to put something in so it makes the active/current cell color yellow.
View 5 Replies
View Related
Sep 30, 2006
I'm trying to create a simple VBA function in Excel so that I can sort and calculate results based on various conditions. I can get everything to work except changing the color of the cell where the output is placed. Here is what I have so far:
Function nameOfMyFunction(arguments)
If conditions Then
nameOfMyFunction = "No GRP"
ActiveCell.Font.Color = RGB(255,0,0)
End If
I'm sure that its something simple, but I've spent long enough on my own trying to figure it out and nothing seems to work.
View 5 Replies
View Related
Sep 11, 2007
I am trying to utilise the color function code i have previously asked for help with on this site in a new spreadsheet i have included the code below for your reference. I am utilising the following formula to total the numbers in the cells coloured =colorfunction(J1,E1:E26,True)
Excel keeps returning the following error 'cant find project or library'
Option Explicit
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function
View 9 Replies
View Related
Feb 1, 2014
I am looking to color code items in a list box called lbActiveItemList, is this possible? If so I would like it to color code based on the value in the 3rd column as follows:
If the value = 'Receive' Color code the item line as Black
If the value = 'Return' Color code the item line as Blue
If the value = 'Relocate' Color code the item line as Green
If the value = 'Lost' or 'Damaged' color code the item line as Red
View 3 Replies
View Related
Jan 28, 2012
Is there some code to change the fill color of all the combo boxes I have on a spreadsheet.
View 2 Replies
View Related
Sep 24, 2013
VBA code to do the following.
In F147 will go a value
Then if the value of F147 is greater than 20 the color of D144 would turn green.
View 3 Replies
View Related
Apr 25, 2007
I am trying to a macro that allows me to change the backgroud color and font color depending of the value of the cell.
For example is cell A1 is having the value between 1 to 3 the background color of the cell will the light turqoise, if the value is between 4 to 20 the cell background color will be green and so on.
I have based on certain posted example and adapt to my code but somehow it is not working.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Select Case Target.Value
Case Is = 1, 2, 3
Target.Interior.ColorIndex = 34
Case Is = 4, 5, 10, 20
Target.Interior.ColorIndex = 43
Case Is = 30, 40, 50
View 9 Replies
View Related
Jan 22, 2008
I would like to have a vba code that changes the cell color so that if there is number 1 (just number 1) in some cell the background of the cell changes in to shade of grey and cell that has number 2 changes into darker shade of grey and so on. I have numbers 1-10 in random order in my sheet. I mean there is many cells that has the same number and the sheet is quite large so vba code would be ideal choise to do it quickly.
View 9 Replies
View Related
Jan 25, 2009
I am wondering if there is any good way of coloring different sections of the source code in excel to show what different programmers have added?
View 9 Replies
View Related
Apr 19, 2009
I am trying to color code mistakes I find when running formulas in a macro. Right now I have it set up to color code mistakes red using the following code after the formula has been inserted in column E.
Range("E2:E75").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""Check"""
Selection.FormatConditions(1).Interior.ColorIndex = 3
My issue is, some of my checks have more than one variable as a wrong answer. For example, one check may include Check and Bad as possible outcomes of the formula in the cell.
the code required to allow two different variables to cause the cells to change color.
I tried a second set of the code for the same column and changed the formulas word to Bad but it did not highlight the cells that came out with Bad as the outcome of the formula.
View 9 Replies
View Related
Apr 29, 2009
I am trying to create a model that has a mixture of conditional formatting and data validation formulas within it, but have run into a problem in one area. Essentially, cell E10 is a Validation which pulls a drop down list of names. One of the options in this list is "Other".
I want to create a VBA code to make sure that cell E12 will get rid of any input, turn grey (color index = 15), and potentially lock (if possible!) if the "Other" is chosen by the user in cell E10. If any other value is chosen for cell E10, Cell E12 needs to remain unlocked and white (color index=2).
View 9 Replies
View Related
Oct 7, 2006
I must highlight cells that appear more than once.
What I mean is that if an item in a cell appears more than once I highlight it in blue, if the same happens twice I highlight that cell red etc and so one. does anyone know how to do this in excel.
View 9 Replies
View Related