PC Review


Reply
Thread Tools Rate Thread

Comparing 4 columns on Two different worksheets.

 
 
Jimbob B
Guest
Posts: n/a
 
      9th Jul 2009



I am trying to create a macro that will compare the data in Cells A
through D on two different sheets. Then post the results on a third
page.

The problem I am haveing is that there will be blanks on both reports
that can not be deleted. For instance on sheet 1 column A3 and A4 maybe
blank but they are assinged to the DATA in B3 and B4. But sheet 2 has
values for this.

I have tried the VLOOP function and that does not seem to be working the
way I need it too.

I have tried many different ways and seem to be getting no where. I
have been working on this project for about a year and I have scrapped
aleast 20 different concepts.

I am running out of paitence. Any Help would be greatly appreciated.

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      9th Jul 2009
Your post is a little vague as to what you expect to see on sheet 3 but
maybe you can work with this and get what you need. Change sheet names to
suit your purposes.

Sub colCompare()
Dim lr1 As Long, lr2 As Long
Dim sh1 As Worksheet, sh2 As Worksheet
Dim sh3 As Worksheet
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
Set sh3 = Sheets("Sheet3")
lr1 = sh1.Cells(Rows.Count, 1).End(xlUp).Row
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr1
For j = 1 To 4
If sh1.Cells(i, j) <> "" And sh2.Cells(i, j) <> "" Then
If sh1.Cells(i, j).Value = sh2.Cells(i, j).Value Then

sh3.Cells(i, j) = "Match"
Else
sh3.Cells(i, j) = "No Match"
End If
End If
Next
Next
End Sub



"Jimbob B" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
>
> I am trying to create a macro that will compare the data in Cells A
> through D on two different sheets. Then post the results on a third
> page.
>
> The problem I am haveing is that there will be blanks on both reports
> that can not be deleted. For instance on sheet 1 column A3 and A4 maybe
> blank but they are assinged to the DATA in B3 and B4. But sheet 2 has
> values for this.
>
> I have tried the VLOOP function and that does not seem to be working the
> way I need it too.
>
> I have tried many different ways and seem to be getting no where. I
> have been working on this project for about a year and I have scrapped
> aleast 20 different concepts.
>
> I am running out of paitence. Any Help would be greatly appreciated.
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
Jim Cone
Guest
Posts: n/a
 
      9th Jul 2009

You can ignore or return blank cells using the IsEmpty function or
by determining the cell length (0 if blank) using the Len function.
Also, checking cells with the TypeName function ensures that you are
doing a comparison on the same type of data...
Range("C1") = ("frog" - 1234) doesn't produce much useful info.
--
Jim Cone
Portland, Oregon USA
(E-Mail Removed)XX (remove xxx)
(trial version of XL Companion available upon request -
compares worksheets, selections, rows) - does other nice stuff too.



"Jimbob B" <(E-Mail Removed)>
wrote in message
I am trying to create a macro that will compare the data in Cells A
through D on two different sheets. Then post the results on a third
page.
The problem I am having is that there will be blanks on both reports
that can not be deleted. For instance on sheet 1 column A3 and A4 maybe
blank but they are assinged to the DATA in B3 and B4. But sheet 2 has
values for this.
I have tried the VLOOP function and that does not seem to be working the
way I need it too.
I have tried many different ways and seem to be getting no where. I
have been working on this project for about a year and I have scrapped
aleast 20 different concepts.
I am running out of paitence. Any Help would be greatly appreciated.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
COMPARING TWO COLUMNS OF INFORMATION, ACROSS TWO WORKSHEETS Susan Microsoft Excel Worksheet Functions 2 5th Jan 2009 11:25 PM
Comparing columns from 2 different worksheets. =?Utf-8?B?QWxhbnQ=?= Microsoft Excel Worksheet Functions 1 8th Jun 2006 03:51 AM
Comparing two worksheets with two columns each for duplicates =?Utf-8?B?amxjbmV3eW9yaw==?= Microsoft Excel Misc 0 15th Feb 2006 02:32 PM
Comparing two columns in two different worksheets =?Utf-8?B?c3RldmVs?= Microsoft Excel Worksheet Functions 4 31st May 2005 01:43 PM
Comparing columns in different worksheets Zachariah Microsoft Excel Worksheet Functions 0 8th Jul 2003 07:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:46 PM.