Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2004, 02:37 PM
Registered User
 
Join Date: Feb 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ever
Default Compare two Items of data(in column A and column B

Hello,

I have a problem. Big time! I am trying to do a comparison of two columns that contain email addresses. If the same email address appears in both column A and Column B. Then I want to Place a '1' or True in column C.

Any help I get on this will be greatly appreciated.

Ever

Music:(

Music
 
Old February 12th, 2004, 03:08 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this
I assume row 1 is your header row so I'll move to row two.
Put this formula into C2
=Iif("A2"="B2","true","false")

This will return true if a2=b2, otherwise it will return false

Let me know if this helps

John

 
Old February 12th, 2004, 03:31 PM
Authorized User
 
Join Date: Nov 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You don't necessarily need to use vba to accomplish this. You can simply place a formula in the cells of column C as follows:

    
Code:
=A1=B1


If the value of cell B1 matches the value of A1 exactly, the value displayed in C1 will be True. Otherwise, C1 will display False.

If you still want the vba code to perform the comparison between two cells, check the Cells Property Example in the VBE help.


Good Luck,



Darrell L. Embrey
 
Old February 13th, 2004, 12:44 PM
Registered User
 
Join Date: Feb 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ever
Default

These are all really good suggestions. However, I don't know where Column A will be equal to Column B. The two like emails may not occur in the same row. They may occur (for example) in cell A2 and Cell B54. I've tried to sort the columns but that doesn't do it.

Thanks

Music
 
Old February 13th, 2004, 12:54 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You will need to use vb and do a comparison loop... while not overly difficult this does require knowledge of vb...what is your ultimate goal...perhaps access is a better application to do this in

John

 
Old February 13th, 2004, 12:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you need to try some form of vlookup eg
Code:
=if(ISNA(VLOOKUP(yourCell, NameOfColARange, False)),0,1)
in col C. Set up a range to define the Column A data (or leave it as cell refs, up to you really). You need the false ion trhere, otherwise it comes up with 'close' matches, not exact.

HTH



There are two secrets to success in this world:
1. Never tell everything you know
 
Old February 13th, 2004, 02:19 PM
Registered User
 
Join Date: Feb 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ever
Default

You Guys,

I figured it out. Thank you so much.
Here is the solution.
And Here it is for anyone who cares.

=MAX(COUNTIF(A:A,B:B))

Elegant, yet effective.

Music





Similar Threads
Thread Thread Starter Forum Replies Last Post
help merge same column data okboy SQL Server 2000 6 July 24th, 2007 01:36 AM
Disappearing Column Data dalezjc Classic ASP Databases 1 November 21st, 2006 09:42 AM
Multi column search and compare luxcs Excel VBA 1 November 16th, 2006 02:45 PM
previous column & next column ct Excel VBA 4 August 19th, 2005 04:50 AM
template column and bound column hidayah ASP.NET 1.x and 2.0 Application Design 1 April 9th, 2005 03:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.