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

i want to know if there is any solution for this query.

i want vba code to compare values of 2 column. and if value of column 1
is higher than that in second value in col one should turn red. if it
is lower than it should turn green & if it is equal then it should
turn blue.

Thanking in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default comapre 2 col.

You can do this using conditional formatting: no code required.

Tim

"Jimish" wrote in message
ups.com...
i want to know if there is any solution for this query.

i want vba code to compare values of 2 column. and if value of
column 1
is higher than that in second value in col one should turn red. if
it
is lower than it should turn green & if it is equal then it should
turn blue.

Thanking in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default comapre 2 col.

yes this is usefull if it is only for one set of col. but if it is for
20 to 25 sets of col. each having 40 to 50 items then it is tough so if
there is any solution for this in vba then it is usefull

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default comapre 2 col.

Can you restate your problem? Reading your original post it's not really
clear what you need to do, since you only reference column1.

Are you comparing values across two different columns on the same row?
Where do values start and end? Should color only change in the first column?
Are the columns next to each other?

tim

--
Tim Williams
Palo Alto, CA


"Jimish" wrote in message
ups.com...
yes this is usefull if it is only for one set of col. but if it is for
20 to 25 sets of col. each having 40 to 50 items then it is tough so if
there is any solution for this in vba then it is usefull



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default comapre 2 col.

i am giving u an example here

A1 value is 230 and B1 value is 225
hence i want value in cell A1 to turn red as it is higher.
this is easy to do with conditional formatting option but it is rather
harder and time consuming if it is to be repeated for A1 : A55 and upto
Z1 : Z55.
So i wanted to know whether there is any solution for that available in
vba code.
And thanks for taking out time for my query.
And thanks again in advance for the hopefull solution



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default comapre 2 col.

and i would also like to know whether it is possible to compare 2 col.
of diffrent sheet and give conditional formating the same way as it is
in the above case. pls give solutions for both diffrently.Tankis once
again.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default comapre 2 col.

Bearing in mind that you can apply conditional formatting to an entire
column at once I agree that this is the easiest solution. If you really
didn't want to do it manually you could use a macro to add the
conditional formatting.

It is still unclear if you want to compare column A to B, B to C, C to D
etc or A to B, C to D, E to F etc.
If the former then you the macro would look something like this;

Sub Frmt()
Dim eRow As Long
Dim eCol As Integer
Dim c As Integer
eCol = Cells(1, Columns.Count).End(xlToLeft).Column - 1
eRow = Cells(Rows.Count, 1).End(xlUp).Row
For c = 1 To eCol
With Range(Cells(1, c), Cells(eRow, c))
.Cells(1, c).Activate
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression _
, Formula1:="=RCRC[1]"
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions.Add Type:=xlExpression _
, Formula1:="=RC<RC[1]"
.FormatConditions(2).Font.ColorIndex = 10
.FormatConditions.Add Type:=xlExpression _
, Formula1:="=RC=RC[1]"
.FormatConditions(3).Font.ColorIndex = 5
End With
Next c
End Sub

Hope this helps
Rowan

Jimish wrote:
i am giving u an example here

A1 value is 230 and B1 value is 225
hence i want value in cell A1 to turn red as it is higher.
this is easy to do with conditional formatting option but it is rather
harder and time consuming if it is to be repeated for A1 : A55 and upto
Z1 : Z55.
So i wanted to know whether there is any solution for that available in
vba code.
And thanks for taking out time for my query.
And thanks again in advance for the hopefull solution

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
Match data then comapre and return new data [email protected] Excel Worksheet Functions 0 June 18th 08 12:53 PM
Macro for comapre and copy Arain Excel Discussion (Misc queries) 13 April 18th 07 11:16 PM
comapre two list of data & arranging in a same manner Sachin New Users to Excel 1 November 25th 06 01:28 PM
comapre two lists mansure Excel Discussion (Misc queries) 2 November 28th 04 01:57 PM
How do i comapre 2 columns Tom Ogilvy Excel Programming 0 September 3rd 04 07:25 PM


All times are GMT +1. The time now is 09:21 AM.

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"