Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default calculation based on row and column values


I have the above vba, which loops thru rows b9 to 383 and checks th
cell values, colouring the cells in G depending upon the result.
My question is this = at the moment this is only usable for checking
against BF. What I would like is for it to go from bF to CJ and chec
each row value against row 385 for each row.
Thanks for help anyone.



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

End Su

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default calculation based on row and column values

AmyTaylor

you could try something like this:

Sub TrafficLights2()
Dim iRow As Integer
Dim iColumn As Integer
Dim Pcent As Integer
Pcent = 0.05
Application.ScreenUpdating = False
For iColumn = 58 To 88 ' number range relates to columns BF to CJ
For iRow = 9 To 383 ' note the number range relates to the rows
If Cells(iRow, iColumn).Value _
< Cells(385, iColumn).Value + Pcent Then
Cells(iRow, iColumn).Interior.Color = vbGreen
Else
Cells(iRow, iColumn).Interior.Color = vbRed
End If
Next iRow
Next iColumn
Application.ScreenUpdating = True
End Sub

But I think you'd be far better using Conditional Formatting.

Regards

Trevor


"AmyTaylor" wrote
in message ...

I have the above vba, which loops thru rows b9 to 383 and checks the
cell values, colouring the cells in G depending upon the result.
My question is this = at the moment this is only usable for checking B
against BF. What I would like is for it to go from bF to CJ and check
each row value against row 385 for each row.
Thanks for help anyone.



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

End Sub


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



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
I need to do a calculation based on the values in two cells NakesGP Excel Worksheet Functions 2 August 23rd 09 10:33 PM
Calculation based on Y or N Values Malcolm McMaster[_2_] Excel Discussion (Misc queries) 2 October 17th 07 07:16 AM
Adding numerical values based on multiple values in another column Kazmaniac Excel Worksheet Functions 6 April 4th 07 08:53 PM
how to substitute a value for calculation with a column of values Peiru Excel Worksheet Functions 1 April 2nd 06 02:02 PM
Calculating values to column D with formula based on values column A spolk[_2_] Excel Programming 1 April 30th 04 06:29 PM


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