#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default So close

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 34
Default So close

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default So close

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default So close

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 173
Default So close

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default So close

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default So close

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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default So close

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why excel close all files when I just want to close one files hon123456 Excel Discussion (Misc queries) 2 December 8th 10 12:12 PM
why do all excel worksheets/workbooks close when I close one? Penny Excel Discussion (Misc queries) 1 November 29th 06 03:49 AM
close button does not close goplayoutside Excel Discussion (Misc queries) 1 October 11th 05 03:42 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


All times are GMT +1. The time now is 02:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"