Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Can anyone help me out here? I want to change the font color of a cell
depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
On May 11, 2:38 pm, "E2out" wrote:
Can anyone help me out here? I want to change the font color of a cell depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP Not sure what you want to do here but it looks like you are missing an "ELSE" between your two sets of the color. |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I tried it with the "else" and it still didn't work. What I'm trying to do
inside this spreadsheet is to run a macro that will test for a cell value and if it falls as true inside the (3<cell value<34) then the font will change to red. I know I'm close to getting it but I've tested it with different values in "B2" but the font color will not change. "Edward" wrote in message oups.com... On May 11, 2:38 pm, "E2out" wrote: Can anyone help me out here? I want to change the font color of a cell depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP Not sure what you want to do here but it looks like you are missing an "ELSE" between your two sets of the color. |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Sub nums()
Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If 5 < a _ and a < 8 Then 'You're changing B2 twice?????? Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub E2out wrote: Can anyone help me out here? I want to change the font color of a cell depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I assume you can't just use Format/Conditional Format - based on the cell
value(?). Will "E2out" wrote: Can anyone help me out here? I want to change the font color of a cell depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP |
#6
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Thanks 4 the reply but don't know how... :(
"roadkill" wrote in message ... I assume you can't just use Format/Conditional Format - based on the cell value(?). Will "E2out" wrote: Can anyone help me out here? I want to change the font color of a cell depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP |
#7
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
So in other words I have to break up the conditional test?
(any number< cell value < bigger number) I'm not trying to change "B2" twice. What I'm trying to do is change the font color if the value lies in between the range or change it to the second color if it doesn't Again I have to be so close on this one... Thanks again.... So I have to throw an "Else" in there? "Dave Peterson" wrote in message ... Sub nums() Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If 5 < a _ and a < 8 Then 'You're changing B2 twice?????? Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub E2out wrote: Can anyone help me out here? I want to change the font color of a cell depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
How about something like:
Sub nums() Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If 5 < a _ and a < 8 Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) else Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub You may want to look at format|Conditional formatting. You can change the color of the font based on what the formula evaluates to. E2out wrote: So in other words I have to break up the conditional test? (any number< cell value < bigger number) I'm not trying to change "B2" twice. What I'm trying to do is change the font color if the value lies in between the range or change it to the second color if it doesn't Again I have to be so close on this one... Thanks again.... So I have to throw an "Else" in there? "Dave Peterson" wrote in message ... Sub nums() Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If 5 < a _ and a < 8 Then 'You're changing B2 twice?????? Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub E2out wrote: Can anyone help me out here? I want to change the font color of a cell depending on a conditional test (4<cell contents<90) Here is my code Sub nums() Worksheets("sheet1").Activate Range("b2").Select Range("b2").Activate Dim a As Integer a = Worksheets("sheet1").Range("b2").Value If (5 < a < 8) Then Worksheets("sheet1").Range("b2").Font.Color = RGB(255, 0, 0) Worksheets("sheet1").Range("b2").Font.Color = RGB(0, 0, 255) End If End Sub Thanks! JP -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Why excel close all files when I just want to close one files | Excel Discussion (Misc queries) | |||
why do all excel worksheets/workbooks close when I close one? | Excel Discussion (Misc queries) | |||
close button does not close | Excel Discussion (Misc queries) | |||
Excel shoud not close all active books when clicking close button | Excel Discussion (Misc queries) | |||
excel - Windows close button (x) should only close active workboo. | Setting up and Configuration of Excel |