Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Compare Two Columns of Data Using VB Excel

Hello . . .

I would like to compare two columns of data, against each other, usin
visual basic for Excel.

I have four columns: A, B, C, & D.

Columns A and B have the initial data. Columns C and D will have th
resulting data.

Columns C displays a message "OK" if the data in cell B1 is found
anywhere in column A. This is also true for cells B2, B3, and so on .
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Compare Two Columns of Data Using VB Excel

Hi

Something like:
Sub aaa()
Range("a1").Select
While Not IsEmpty(ActiveCell)
If WorksheetFunction.CountIf(Range("b:b"), ActiveCell)
0 Then
ActiveCell.Offset(0, 3) = "OK"
Else
ActiveCell.Offset(0, 3) = "Name in Col A is not in Col
B"
End If
ActiveCell.Offset(1, 0).Select
Wend
Range("b1").Select
While Not IsEmpty(ActiveCell)
If WorksheetFunction.CountIf(Range("a:a"), ActiveCell)
0 Then
ActiveCell.Offset(0, 1) = "OK"
Else
ActiveCell.Offset(0, 1) = "Name in Col B is not in Col
A"
End If
ActiveCell.Offset(1, 0).Select
Wend
End Sub


Tony
-----Original Message-----
Hello . . .

I would like to compare two columns of data, against each

other, using
visual basic for Excel.

I have four columns: A, B, C, & D.

Columns A and B have the initial data. Columns C and D

will have the
resulting data.

Columns C displays a message "OK" if the data in cell B1

is found
anywhere in column A. This is also true for cells B2, B3,

and so on . .
.

Column C displays a message "Name In Col B Is Not In Col

A" if the data
in cell B1 is not found anywhere in Column A. This is

also true for
cells B2, B3, and so on . . .

The number of rows, with respect to Columns A and B,

varies from day to
day.

Presently I am able to achieve this task using the

following formula
for Columns C:

=IF(COUNTIF(A:A,B2)<0,"OK","Name In Col B Is Not In Col

A")

and for Columns D this formula is used:

=IF(COUNTIF(B:B,A2)<0,"OK","Name In Col A Is Not In Col

B")

How can I do this same task in a VB macro with the number

of rows
varying daily?

Thank you for any help . . . . Regards,


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Compare Two Columns of Data Using VB Excel

Tony,

Thank you for the response and code.

It works.

Regards, (willik

--
Message posted from http://www.ExcelForum.com

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
Compare the data in 2 columns Raj Excel Discussion (Misc queries) 1 December 29th 08 10:05 AM
compare data in two columns Kim Excel Worksheet Functions 2 April 12th 07 03:14 PM
Compare data in two columns excellearn2006 Excel Worksheet Functions 2 August 17th 06 11:13 PM
Excel Formula or tool to compare two columns of data RBS Excel Worksheet Functions 3 April 14th 06 06:54 PM
Need to compare data in 2 columns and not sure how. Stacey Charts and Charting in Excel 0 February 8th 06 04:47 PM


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