Wrox Programmer Forums
|
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 13th, 2004, 12:48 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 HELP!

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.

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.

Any help I get on this will be greatly appreciated.
Ever
:(

Music
 
Old February 14th, 2004, 06:40 PM
Registered User
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ever

You need to sort each column individually and then the sort function will work, I tested this in Excel. After you have sorted the columns, then use an IF statement to compare the two columns. E.g formula would be =IF(A1=B1,1,"").

If this does not work another alternative would be to use the following formula: =IF(COUNTIF(A1:A3,B1),1,"")and then you do not need to use the sort function.

Hope these suggestions helps
Regards
Llewellyn
 
Old February 15th, 2004, 04:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe you can use this one:

Sub RowNoOfDublet()
Dim a, b, c As Integer
a = 1
b = 1

Application.ScreenUpdating = False
For b = 1 To 50 '(50 is the No of rows in col B)
    For a = 1 To 50 '(50 is the No of rows in col A)
        Cells(a, 1).Select
        If Cells(a, 1).Value = Cells(b, 2).Value Then
            Cells(b, 3).Value = Cells(a, 1).row
        End If
    Next a
Next b
Application.ScreenUpdating = True

End Sub

In col C it states in which row in A the dublet is found. If you want it only to state a 'True' then replace:

            Cells(b, 3).Value = Cells(a, 1).row
with
            Cells(b, 3).Value = "True"









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