Computing.Net > Forums > Office Software > Columns comparing

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Columns comparing

Reply to Message Icon

Name: Linkas
Date: July 8, 2009 at 03:58:50 Pacific
OS: Windows XP
Product: Microsoft Excel 2003 eng bus-6.0
Subcategory: Microsoft Office
Comment:

Hi everyone.

I'm trying to make a macro that can verifity two columns (in diferent sheets), now the data from one of the sheets is constantly updated. i wanted a macro to verifiy if one (of two fields) in column 2 exist.

If it does, then it wouldnt do anything. if it doesn't, it would add the data from column 1 (several cells, not just one, but in the same row).

The biggest problem is that mostly macro i've seen are really slow. i have about 1800 rows in column 2, while column 1 usually has about 800 or so.

can anyone give me a hand?

this is a macro i've seen and have been working on it...

Sub FindMissing()
Dim myRange1, myRange2, cel As Range

Set myRange1 = Sheets("Sheet1").Range("A1", Sheets("Sheet1").Range("A1").End(xlDown))
For Each cel In myRange1
Set myRange2 = Sheets("Sheet2").Range("A1", Sheets("Sheet2").Range("A1").End(xlDown))
With myRange2
If .Find(What:=cel, LookAt:=xlWhole, searchorder:=xlByRows, searchdirection:=xlNext) Is Nothing Then
'MsgBox cel
Sheets("Sheet2").Range("A1").End(xlDown).Offset(1, 0) = cel
End If
End With
Next
End Sub


with this macro i've only managed to fill one cell and only check one field (i have to verify Two).

thanks in advance to everyone who took the time to read this



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: July 8, 2009 at 07:23:28 Pacific
Reply:

re: verifiy if one (of two fields) in column 2 exist".

I don't understand what you mean by this. What do you mean by a "field"?

re: if it doesn't, it would add the data from column 1 (several cells, not just one, but in the same row).

I assume that you mean that you are comparing the data in Sheet1-Column 1 to Sheet2-Column1 and then trying to copy (for example) Sheet1!Ax:Gx. Is that right?

re: The biggest problem is that mostly macro i've seen are really slow

- I put 1800 entries in Sheet(2)!A1:A1800
- I put 800 entries in Sheet(1)!A1:A800, none of which were in the Sheet2 list.
- I ran your code and it took less than 1 second to add all 800 entries to the bottom of the list in Sheet2.

What's your definition of "really slow"?


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Columns comparing

rows+columns compare and count www.computing.net/answers/office/rowscolumns-compare-and-count/7802.html

Excel Formula - Compare two columns www.computing.net/answers/office/excel-formula-compare-two-columns/7308.html

Excel - Compare columns for differe www.computing.net/answers/office/excel-compare-columns-for-differe/7765.html