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 Lists

I could use some help with validating items in a list with VBA. What
I would like to do is compare List A and List B. If an item is in
List A but not in List B I would like to delete item from List A.

Thanks for any help available.

Regards,

David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Compare Lists

I haven't got the code to hand but you can achieve your
requirement by using the Filter function .. see the VBA
help files for documentation and example. Filter also
copes with case sensitivity.

-----Original Message-----
I could use some help with validating items in a list

with VBA. What
I would like to do is compare List A and List B. If an

item is in
List A but not in List B I would like to delete item from

List A.

Thanks for any help available.

Regards,

David
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Compare Lists

use the match function


eg

sub quicktest()
for rw = firstrow to lastrow' of 'A'
item = cells(rw,cl) ' cl is the column letter of A
if notmatched(item) then
cells(rw,cl=""
end if
next
end sub
function notmatched(item as string) as boolean
on error resume next
dim res
res = Application.WorksheetFunction.Match(item,range
("b1:b100")
if err.number= 0 then
' matched
notmatched = false
else
err.clear
notmatched = true
end if
end function


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
I could use some help with validating items in a list

with VBA. What
I would like to do is compare List A and List B. If an

item is in
List A but not in List B I would like to delete item

from List A.

Thanks for any help available.

Regards,

David
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Compare Lists

Here's some sample code:

Sub VerifyA()
a = Split("Jan,Feb,Mar,Apr", ",")
b = Split("Jan,Mar,Apr,May", ",")
c = a
For i = LBound(a) To UBound(a)
If -1 = UBound(Filter(b, a(i), True,
vbTextCompare)) Then
c = Filter(a, a(i), False, vbTextCompare)
End If
Next
a = c
MsgBox Join(a) ' will keep Jan,Mar,Apr in a
End Sub


-----Original Message-----
I haven't got the code to hand but you can achieve your
requirement by using the Filter function .. see the VBA
help files for documentation and example. Filter also
copes with case sensitivity.

-----Original Message-----
I could use some help with validating items in a list

with VBA. What
I would like to do is compare List A and List B. If an

item is in
List A but not in List B I would like to delete item

from
List A.

Thanks for any help available.

Regards,

David
.

.

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 lark Excel Worksheet Functions 3 May 6th 08 02:12 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 Vicki Needs Help New Users to Excel 1 May 11th 07 03:46 AM


All times are GMT +1. The time now is 11:03 PM.

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"