Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / October 2006

Tip: Looking for answers? Try searching our database.

Compare Two Rows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
smandula@idirect.com - 03 Oct 2006 15:03 GMT
Can anyone provide a VBA macro?
To compare two rows of  values, if the lower row value equals
the upper row value color both values green.
Need this across 70 columns

Example:

Row   1       0   1    4    4    5   6    7
Row   2       4   4    8    4    9    0   8

4 in Row 1 & Row 2 would be highlited

With Thanks
dolivastro@gmail.com - 03 Oct 2006 15:37 GMT
First select the data you want compared.  Then use this script:

dim r as long
dim c as long

for r = 1 to selection.rows.count
    if (selection.cells(r,1).value = selection.cells(r,2).value) then
         for c = 1 to 2
              selection.cells(r,c).interior.colorindex = 3
              selection.cells(r,c).interior.pattern=xlSolid
          next c
     end if
next f

Hope this helps
Dom

> Can anyone provide a VBA macro?
> To compare two rows of  values, if the lower row value equals
[quoted text clipped - 9 lines]
>
> With Thanks
Bernard Liengme - 03 Oct 2006 15:39 GMT
No need for a macro; can be done using Format | Conditional Formatting with
Formula is =A2=A3
best wishes
Signature

Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

> Can anyone provide a VBA macro?
> To compare two rows of  values, if the lower row value equals
[quoted text clipped - 9 lines]
>
> With Thanks
CLR - 03 Oct 2006 16:37 GMT
What you desire can be easily accomplished with the Excel feature called
Conditional Formatting......no macro required.
First, highlight cells A1 and A2, then do Format > ConditionalFormat > then
in the left window select "Formula is" and in the right window type the
formula
=AND(SUM(A$12:A$13)>0,A$12=A$13), then select the Format button on the
pop-up and choose the Patterns Tab, and click on a Green square, then ok >
ok,  Then, highlight the same two cells and select the FormatPainter icon in
the upper toolbar, (the little paintbrush), and drag it across all the cells
you wish to format the same.......ie, your 70 columns.  This will  make the
cells turn green if they are matching in value and ARE NOT ZERO, OR
EMPTY.......

hth
Vaya con Dios,
Chuck, CABGx3

> Can anyone provide a VBA macro?
> To compare two rows of  values, if the lower row value equals
[quoted text clipped - 9 lines]
>
> With Thanks
Bruno - 03 Oct 2006 18:47 GMT
There is the mistake in the formula:
A$12 should be A$1, and A$13 sholud be A$2. I also tried it and after I
corrected cell references it works perfectly.
Bruno
CLR - 03 Oct 2006 18:56 GMT
Good "catch"  Bruno.........I did my testing a little further down the sheet
and forgot to convert when I posted........

Vaya con Dios,
Chuck, CABGx3

> There is the mistake in the formula:
> A$12 should be A$1, and A$13 sholud be A$2. I also tried it and after I
> corrected cell references it works perfectly.
> Bruno
smandula@idirect.com - 03 Oct 2006 21:25 GMT
Thanks for all your relies.

However, I was hoping for a VBA solution.

With Thanks
smandula@idirect.com - 04 Oct 2006 03:23 GMT
Created a VBA solution myself.

Thanks for Looking, to all respondents
Lars - 04 Oct 2006 10:59 GMT
>Created a VBA solution myself.
>
>Thanks for Looking, to all respondents

I think you should share your solution with us!
That is was Usenet is all about.

Lars
Stockholm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.