Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default variation of 2 rows


I have the following code, which looks at the cells BF9, BF10 etc and i
the corresponding cell J9, J10 etc is greater then cell G9, G10 et
changes colour.

What I really want is to use the Pcent value (ie: 5%) to make th
calculation a bit more complicated, whereby the value has to be 5
greater or 5% lower to trigger a change in the colours.

Sub TrafficLights()
Dim R As Integer
Dim Pcent As Integer
Pcent = 0.05
For R = 9 To 383 ' note the number range
If Range("BF" & R).Value < Range("J" & R).Value Then
Range("G" & R).Interior.Color = vbGreen
Else
Range("G" & R).Interior.Color = vbRed
End If
Next R
End Sub

I hope this makes sense, and hope someone can help me
Thank you
Amy x

--
AmyTaylo
-----------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...fo&userid=2097
View this thread: http://www.excelforum.com/showthread.php?threadid=38838

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default variation of 2 rows

Hi,

Try this: note pcent should be DIMed as DOUBLE not INTEGER

Sub TrafficLights()
Dim R As Integer
Dim Pcent As Double
Pcent = 0.05
For R = 9 To 20 ' note the number range
' Greater than 5% less
If Range("A" & R).Value * (1 + Pcent) < Range("J" & R).Value Then
Range("G" & R).Interior.Color = vbGreen
Else
' greater than 5% more
If Range("A" & R).Value Range("J" & R).Value * (1 + Pcent) Then
Range("G" & R).Interior.Color = vbRed
End If
End If
Next R
End Sub

HTH

"AmyTaylor" wrote:


I have the following code, which looks at the cells BF9, BF10 etc and if
the corresponding cell J9, J10 etc is greater then cell G9, G10 etc
changes colour.

What I really want is to use the Pcent value (ie: 5%) to make the
calculation a bit more complicated, whereby the value has to be 5%
greater or 5% lower to trigger a change in the colours.

Sub TrafficLights()
Dim R As Integer
Dim Pcent As Integer
Pcent = 0.05
For R = 9 To 383 ' note the number range
If Range("BF" & R).Value < Range("J" & R).Value Then
Range("G" & R).Interior.Color = vbGreen
Else
Range("G" & R).Interior.Color = vbRed
End If
Next R
End Sub

I hope this makes sense, and hope someone can help me
Thank you
Amy xx


--
AmyTaylor
------------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970
View this thread: http://www.excelforum.com/showthread...hreadid=388380


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default variation of 2 rows


Hi, thank you for your reply, but I cant get it to work :(
Can I send you a copy of the file for you to look at ?
Amy x

--
AmyTaylo
-----------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...fo&userid=2097
View this thread: http://www.excelforum.com/showthread.php?threadid=38838

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default variation of 2 rows


Hi, please disregard my last email, I have figured it out - I shoul
have been entering .5, not 0.05 thank you anyay !!

Amy xxxxxxx

--
AmyTaylo
-----------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...fo&userid=2097
View this thread: http://www.excelforum.com/showthread.php?threadid=38838

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default variation of 2 rows

Hi,
It should be 0.05 if you did mean 5%; 0.5 is 50%.

"AmyTaylor" wrote:


Hi, please disregard my last email, I have figured it out - I should
have been entering .5, not 0.05 thank you anyay !!

Amy xxxxxxxx


--
AmyTaylor
------------------------------------------------------------------------
AmyTaylor's Profile: http://www.excelforum.com/member.php...o&userid=20970
View this thread: http://www.excelforum.com/showthread...hreadid=388380


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
Sumproduct with variation Qikslvr Excel Discussion (Misc queries) 1 February 23rd 10 11:30 PM
Using some variation of int or trunc april Excel Discussion (Misc queries) 1 August 10th 09 09:44 PM
Variation on If Then Else Theme DubboPete Excel Discussion (Misc queries) 2 April 17th 09 03:17 AM
Variation from the mean? Greenwich_Man Charts and Charting in Excel 1 September 25th 07 03:14 PM
SUMIF variation? Bob Newman Excel Worksheet Functions 8 June 18th 06 09:13 PM


All times are GMT +1. The time now is 08:56 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"