Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can someone help me determine what is wrong with the following code.
I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Red()
Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom,
I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
do you absolutely need this to run in a macro. could you instead use the
conditional formatting function provided with Excel? Formatting Conditional Formating ? "Ed P" wrote: Tom, I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Red()
Range("F9:G9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub worked fine for me with F9:G9 merged. cell was formatted as percentage and was displaying 101% from the immediate window you can see the actual value stored in the cell: ? ActiveCell.Value 1.01 I guess you need to see what value is actually stored in the cell. Sub Red() Range("F9:G9").Select MsgBox "Value: " & ActiveCell.Value & _ " Display: " & ActiveCell.Text If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub -- Regards, Tom Ogilvy "Ed P" wrote in message ... Tom, I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ben, If you are meaning something like this:
[Green] [<=1] 0.0%; [Red] [1] ##0.0%; Percentage Then yes I have tried that as well. I have not been able to get this to work using any method. If you have other suggestions I am all ears. Thanks for your help Ed "ben" wrote: do you absolutely need this to run in a macro. could you instead use the conditional formatting function provided with Excel? Formatting Conditional Formating ? "Ed P" wrote: Tom, I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom,
With your suggestion I have discoverd that the problem is not laying within my code but rather the execution of the code. I need this macro to run anytime the cell reaches 100.01%. Do you have any suggestions for this. We are taking a step in the right direction. I appreciate your help on this. Thank You Ed "Tom Ogilvy" wrote: Sub Red() Range("F9:G9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub worked fine for me with F9:G9 merged. cell was formatted as percentage and was displaying 101% from the immediate window you can see the actual value stored in the cell: ? ActiveCell.Value 1.01 I guess you need to see what value is actually stored in the cell. Sub Red() Range("F9:G9").Select MsgBox "Value: " & ActiveCell.Value & _ " Display: " & ActiveCell.Text If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub -- Regards, Tom Ogilvy "Ed P" wrote in message ... Tom, I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
[Green] [<=1] 0.0%; [Red] [1] ##0.0%;
worked fine for me as well. (formated the merged cells). Ben probably wants you to try Format=Conditional Formatting Regards, Tom Ogilvy "Ed P" wrote in message ... Ben, If you are meaning something like this: [Green] [<=1] 0.0%; [Red] [1] ##0.0%; Percentage Then yes I have tried that as well. I have not been able to get this to work using any method. If you have other suggestions I am all ears. Thanks for your help Ed "ben" wrote: do you absolutely need this to run in a macro. could you instead use the conditional formatting function provided with Excel? Formatting Conditional Formating ? "Ed P" wrote: Tom, I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
We got it fugured out...
Thanks for all your help Ed "Tom Ogilvy" wrote: Sub Red() Range("F9:G9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub worked fine for me with F9:G9 merged. cell was formatted as percentage and was displaying 101% from the immediate window you can see the actual value stored in the cell: ? ActiveCell.Value 1.01 I guess you need to see what value is actually stored in the cell. Sub Red() Range("F9:G9").Select MsgBox "Value: " & ActiveCell.Value & _ " Display: " & ActiveCell.Text If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub -- Regards, Tom Ogilvy "Ed P" wrote in message ... Tom, I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Right click on the sheet tab and select view code. Put in code like this.
Private Sub Worksheet_Calculate() With Range("F9:G9") If IsError(.Item(1, 1).Value) Then .Font.ColorIndex = xlAutomatic Else If .Item(1, 1).Value 1 Then .Font.ColorIndex = 3 Else .Font.ColorIndex = 4 End If End If End With End Sub -- Regards, Tom Ogilvy "Ed P" wrote in message ... Tom, With your suggestion I have discoverd that the problem is not laying within my code but rather the execution of the code. I need this macro to run anytime the cell reaches 100.01%. Do you have any suggestions for this. We are taking a step in the right direction. I appreciate your help on this. Thank You Ed "Tom Ogilvy" wrote: Sub Red() Range("F9:G9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub worked fine for me with F9:G9 merged. cell was formatted as percentage and was displaying 101% from the immediate window you can see the actual value stored in the cell: ? ActiveCell.Value 1.01 I guess you need to see what value is actually stored in the cell. Sub Red() Range("F9:G9").Select MsgBox "Value: " & ActiveCell.Value & _ " Display: " & ActiveCell.Text If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub -- Regards, Tom Ogilvy "Ed P" wrote in message ... Tom, I apprecaite your help. I have entered the Code as you instructed, but it still is not working correctly. I had originally chose 2 cells because those cells are merged. I am not sure if this is the problem or not. Do you have any other suggestions? Thanks again for your help. Ed "Tom Ogilvy" wrote: Sub Red() Range("F9").Select If ActiveCell.Value 1 Then ActiveCell.Font.ColorIndex = 3 End If End Sub would be what i would try if your cells contains percentages. Also, if you are only working with the activecell, why select more than one cell. -- Regards, Tom Ogilvy "Ed P" wrote in message ... Can someone help me determine what is wrong with the following code. I am needing to change the color of the text in a cell to red if the cell is 100%. My code I have currently is follows. Sub Red() Range("F9:G9").Select If ActiveCell.Value 100 Then ActiveCell.Font.ColorIndex = 3 End If End Sub I appreciate any help you can give me. If I am taking the wrong approach please advise. Thank You Ed |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to format cells for the font to change color depending on how
the number relates to another cell on the row. I am using Format/Conditional. When I use the Paste Format function, the orginal comparing cell from the original row is reflected instead of the appropriate row's cell. How do I copy the format so it reflects each individual row's criteria? I appreciate your help! ~ Barbara[quote:bfa81e434e][/quote:bfa81e434e] |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Make sure any cell references in your condition are relative (eg.
"A1") and not absolute ("$A1$") They should then automatically adjust when pasted. Tim. "bgpip - ExcelForums.com" wrote in message ... I need to format cells for the font to change color depending on how the number relates to another cell on the row. I am using Format/Conditional. When I use the Paste Format function, the orginal comparing cell from the original row is reflected instead of the appropriate row's cell. How do I copy the format so it reflects each individual row's criteria? I appreciate your help! ~ Barbara[quote:bfa81e434e][/quote:bfa81e434e] |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formatting Problem | New Users to Excel | |||
formatting problem | Excel Discussion (Misc queries) | |||
csv to xls formatting problem | Excel Discussion (Misc queries) | |||
formatting problem | Excel Discussion (Misc queries) | |||
Formatting problem | Excel Discussion (Misc queries) |