I'm unable to create a rule in Conditional Formatting for this requirement. I was tried using this option "Use a formula to determine which cells to format" inside the rule but didnt get proper formulae.
My Requirement:
If I change the Activity value to Completed in column A then accordingly the font color should be in (Sky blue) and font size is (10) in columns B and C.
If I change the activity value to Delayed in column A then the font color should be in (Red) and font size is (Default or no change) in columns B and C.
Also if I manually type to change the Activity type from To Do to Completed then the Final Date column field value should be automatically filled with the current or Today's date which is as on date.
What formulae I can use for this requirement? How?
Changing the text format is easy to solve with Conditional Formatting, changing the cell's text to today's date requires VBA.
1. Text format
Select cells B2:C10
Create a conditional format with "Use a formula to determine which cells to format". Enter this formula:
=$A2="Completed"
Click the 'Format' button and apply the blue text color and your desired font size.
Repeat the steps using this formula:
=$A2="Delayed"
Apply the red font color.
2. Enter today's date via VBA
Open the VBA editor with Alt+F11
Double click the worksheet on the left hand panel where your Activity table is placed (i.e. Sheet1).
Enter this code in the right hand code panel:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Value2 = "Completed" Then
Cells(Target.Row, 3).Value = Date
End If
End Sub
Related
I'm currently doing a small side project where I'm converting images into excel spreadsheets. I have a python program which turns each cell into a range between 0 and 255 (RGB color codes).
I had made this a while back and don't actually remember how I colored each row with conditional formatting.
Essentially, I need to select each row, turn it a shade of red. Then I need to select each alternate row (MOD 2 = 0) and turn each of those into a shade of green. Finally, I need to select each third row (MOD 3 = 0) and turn those into a shade of blue.
Again, to reiterate, I'm having trouble with actually selecting the rows. Is there any way I can do this (without doing it by hand)?
Check the following:
Highlight rows to get formatted
Click on "Conditional Formatting" and then "New Rule"
Click the last option on the upper part of the box "Use a formula to determine which cells to format"
Type this =MOD(ROW(),1)=0
Click "Format" and select a fill color (Red in this example)
Repeat it two more time for the other two colors
=MOD(ROW(),2)=0 for Green & =MOD(ROW(),3)=0 for Blue
check the below image
I would like to change the currency symbol in a cell depending on the value in another cell, in the row.
For example if cell A1 contains "EU" then cell A2 will be "€ 5.00" (If the calculation was 3+2), and if the content in cell A1 were to be changed to "GB" then £ 5.00 will display in A2.
Is is possible to do this in VBA? I would prefer NOT to do a simple IF statement.
You most certainly can! Utilize conditional formatting on your range with the currency value. Here is how I accomplished this in a test...
Select the first cell in your "amount" range and then click Conditional Formatting -> New Rule.
Select "Use a formula to determine which cells to format"
In the box, type =if([Cell w/ Country] = "USA", 1, 0 ). Note, [Cell w/ Country] is whatever cell that indicates the type of currency. In my example, the formula is =if($A6="USA", 1, 0). [Pay close attention to the cell reference $A6 - you want the formula to work for the entire column (in this example), so don't enter $A$6.]
After typing the formula, click the "Format" button.
Click on the "Number" tab and choose "Currency" in the Category list
Using the Symbol dropdown, select the symbol corresponding to the rule you just created - in this case, $, then click OK.
Finally, you're left with the Rules Manager window. You'll want to select the range that the rule will apply to. Enter the range, or click the range selector button and highlight the range. Then, click OK.
Here are some screenshots that might be helpful:
Swap around the Country, and the symbol changes.
If it only for one cell then a very short macro will do it.
just change for custom format as within the code:
Sub Macro2()
If Range("a1").Value = "EU" Then Range("A2").Select: Selection.NumberFormat = """€""#,##0"
If Range("a1").Value = "GB" Then Range("A2").Select: Selection.NumberFormat = """£""#,##0"
End Sub
You don't need VBA for this - just good 'ol conditional formatting. With your A2 cell selected, go to Home --> Conditional Formatting. Then click "New Rule" --> "Use a Formula to determine which cells to format".
For the GBP formatting, use the formula =$A$1="GB", then click "Format", go to "Number" along the top, choose "Currency", then just find the GBP symbol. Click "OK" all the way out. There you go!
For the EUR part, repeat the above, but instead use =$A$1="EU" and find EUR symbol in Currency.
Is it possible to clear a large number of cells contents based on color alone? I don't think that simply filtering is going to work well on this because the dataset is large and 'wide'
If you don't need this done programatically, it can be faster to just use Find and Replace (Ctrl-H).
Press Ctrl-H
Click Options > >
Click the top Format... button to search for for colored cells (use the Fill tab)
Leave the Replace with field blank to delete the contents of cells with the format you specified.
This will clear the content of any cell within the range A1:G8 filled with yellow (65535). Change the color for your color and the range for your range. This is kind of crude, sorry.
Sub Macro1()
Range("A1:G8").Select
For Each Cell In Selection
If Cell.Interior.Color = Excel.XlRgbColor.rgbYellow Then
Cell.Clear
End If
Next
End Sub
You can clear cells by background color using Excel's filter options.
For Excel 2013 & 2010
Open a worksheet where each column has a header row.
Enable column filtering with Data -> Sort & Filter -> Filter
Click the drop-down-arrow on a column, go to Filter by Color, and select a color you want to view. (Any non-colored cells will be hidden)
Select the remaining cells, right-click and select Clear Contents.
To unhide the remaining cells, disable column filtering with Data -> Sort & Filter -> Filter
I want to know what I would need to type into the formula box in excel to solve the problem outline below:
Key: *Variable/Cell*
IF *cellnumber* = 0 shade cells red
IF *cellnumber* > (more than) 0 but < (less than) *cell number* shade cells yellow
IF *cellnumber = *cellnumber* shade cells green.
You want Conditional Formatting. Pre-Excel 2007 go to the Data menu and click conditional formatting. Excel 2007 or later go to the Home ribbon and click Conditional Formatting. Here is a guide to conditional formatting that shows something similar to what you need.
As for the second and third condition that apply to the value in another cell, you can put a reference in the conditional formatting window similar to "Cell Value : Equal to :" then =$A$1 in the value box.
For 2011:
Any quotes below should NOT be typed. This assumes the cell you want to check against is A1.
Select the range you want to be colored
Home Ribbon -> Conditional Formatting -> Manage Rules
New Rule
"Format Only Cells That Contain"
Choose: Cell Value & between
Enter in "0" and "=$A$1" (remember, no quotes)
Click Format -> Fill, choose yellow
Click Ok
New Rule
"Format Only Cells That Contain"
Choose Cell Value & Equal
Enter in "0"
Click Format -> Fill, choose red
Click Ok
New Rule
"Format Only Cells That Contain"
Choose Cell Value & Equal
Enter in "=$A$1"
Click Format -> Fill, choose green
Click Ok
What we are trying to accomplish is to reference text color in conditionally formatted cells that meet a certain metric. We have a for loop that checks the text color of each cell going down a row.
Colored cells done via conditional formatting can't be referenced via font.color as manually/VBA colored cells are (as far as I know), so we are looking for a way to reference the conditionally formatted color/look in the formatting function and grab the color.
Dim rstarpos As Long
Dim cstartpos1 As Long
rstartpos = 9
cstartpos1 = 3
For i = rstartpos To 10
Sheets("Scorecard").Select
Cells(i, cstartpos1).Select
MsgBox Cells(i, cstartpos1).Font.Color
Font.color would ideally report what the font color of the cell in the loop is. However, because of the conditional formatting it's not. Is there a way to call the conditionally formatted cell's color?
Thanks for your help.
If you're using Excel 2010, you can use the DisplayFormat property of a range to get its displayed format, including the effects of conditional formatting (and table styles). In your example, the last line would change to:
MsgBox Cells(i, cstartpos1).DisplayFormat.Font.Color
Hope this helps.