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 2 lists macro help!


Hello everyone,

I am new to macros in excel. I found a macro that microsoft posted
about comparing two lists or sheets and deletes off of sheet 2, the
ones that are on both sheets. It's hard to explain. For example, I have
a large customer database of 4,000 + names on my sheet2. I want what is
on my sheet 1 (which is my do not call list) to be taken off of sheet2
(the large list). The macro works, but the way it is set up makes me
specify the range and column manually in the code. I am trying to
modify the macro so i can select in the spreadsheet what i want it to
sort through on both sheets. This way i can select the column i want to
use in both sheets instead of manually changing it in the file. Below is
the macro code. Does anyone have any ideas? Thank you.
--------------------------------------------------------------------------
Sub DelDups_TwoLists()
Dim iListCount As Integer
Dim iCtr As Integer

Application.ScreenUpdating = False

' Get count of records to search through (list that will be deleted).
iListCount = Sheets("sheet2").Range("A1:A100").Rows.Count

' Loop through the "master" list.
For Each x In Sheets("Sheet1").Range("A1:A100")
' Loop through all records in the second list.
For iCtr = 1 To iListCount
' Do comparison of next record.
' To specify a different column, change 1 to the column number.
If x.Value = Sheets("Sheet2").Cells(iCtr, 1).Value Then
' If match is true then delete row.
Sheets("Sheet2").Cells(iCtr, 1).EntireRow.Delete
' Increment counter to account for deleted row.
iCtr = iCtr + 1
End If
Next iCtr
Next
Application.ScreenUpdating = True
MsgBox "Done!"
End Sub


--
zaq121
------------------------------------------------------------------------
zaq121's Profile: http://www.excelforum.com/member.php...o&userid=33919
View this thread: http://www.excelforum.com/showthread...hreadid=536978

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 lists Jim S.[_3_] Excel Discussion (Misc queries) 3 October 14th 09 10:30 AM
compare two lists saman110 via OfficeKB.com Excel Discussion (Misc queries) 2 October 16th 07 05:53 PM
Compare two lists ExcelInExcel Excel Discussion (Misc queries) 2 June 8th 07 09:09 PM
Compare two lists? s_tyrone Excel Discussion (Misc queries) 1 November 30th 05 02:47 PM
Compare Lists David Willey Excel Programming 3 August 8th 03 03:25 PM


All times are GMT +1. The time now is 12:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"