Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default trying to format if AHT is found in a range of values

I'm having some issues and hoping you guys might be able to help me
out. I have a variable (AHT), and i'm trying to format a cell in my
spreadsheet based on the value of AHT. I'm about to pull out my hair
trying to figure it out.

If (AHT < 4.03) Then Range("e2").Interior.ColorIndex = 3 -- simple
enough.

Where I get into trouble is here...

If (AHT = 4.03) And (AHT <= 4.33) then Then
Range("e2").Interior.ColorIndex = 45

logically, this makes sense, but I messing something up when stacking
several of these compound if statements together. I've got 7 different
'ranges' that AHT may fall in.

1. if AHT is less than 4.03, e2 fill color should be 3.
2. If AHT is from 4.03 to 4.33 then "e2" fill should be 45
3. if AHT is from 4.34 to 4.66 then "e2" fill should be 6
4. if AHT is from 4.67 to 5.09 then "e2" fill should be 8
5. if AHT is from 5.10 to 5.52 then "e2" fill should be 6
6. if AHT is from 5.53 to 5.95 then "e2" fill should be 45
7. if AHT is greater than 5.95 then "e2" fill should be 3

Since this has to be done via macro, conditional formatting is
unfortunately not an option. Could someone please help me out? Thanks
in advance guys!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default trying to format if AHT is found in a range of values

Hi Mathew,

May l suggest you use a select case statement something like:

AHT = Range("A1")
Select Case AHT
Case AHT < 4.03
Range("E2").Interior.ColorIndex = 3
Case AHT = 4.03 To 4.33
Range("E2").Interior.ColorIndex = 45
etc...........
End Select

Regards

Michael
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default trying to format if AHT is found in a range of values

I wouldn't bother with the lower bound in the Case statements:

AHT = Range("A1").Value
Select Case AHT
Case AHT < 4.03
Range("E2").Interior.ColorIndex = 3
Case AHT < 4.33
Range("E2").Interior.ColorIndex = 45
etc...........
End Select

The first condition satisfied will be used. The remaining won't be checked.


On 06/24/2010 04:33, michael.beckinsale wrote:
Hi Mathew,

May l suggest you use a select case statement something like:

AHT = Range("A1")
Select Case AHT
Case AHT< 4.03
Range("E2").Interior.ColorIndex = 3
Case AHT = 4.03 To 4.33
Range("E2").Interior.ColorIndex = 45
etc...........
End Select

Regards

Michael


--
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
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Conditional format if cell match found in another range of cells Nolene Excel Worksheet Functions 2 October 5th 06 06:56 AM
Identify where max values are found owen080808 Excel Discussion (Misc queries) 4 April 5th 06 10:15 PM
Check if cell value is found in a seperate range of values wilby31[_2_] Excel Programming 1 October 15th 05 12:28 AM
Search a Range for a phrase and Format cell if found [email protected] Excel Programming 3 June 26th 05 10:22 PM


All times are GMT +1. The time now is 03:07 AM.

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

About Us

"It's about Microsoft Excel"