Compare Cells on Sheet to ListBox Selection
Set LBox2 = ListBox2
myList2Company = LBox2.List
Dim DelThisRow(1 to 65000) As String
Dim bfound as Boolean
bFound = False
For r =2 to LastRow
for i = 0 to Ubound(myList2Company,1)
if Cells(r,4).value = MyList2company(i) then
bFound = True
exit for
end if
Next
if Not bFound then
DeleteThisRow(r)="YES"
End If
Next r
--
Regards,
Tom Ogilvy
"NNexcel" wrote in message
...
Hello.
Listbox2 contains selections from Listbox1. I want to be able to see if
the value of a cell on a sheet is contained within the values of Listbox2.
I
can not figure out a code that will allow me to say something similar to
"If
Range(ColumnD & r).Value NOT IN myList2Company Then..."
Thank you for your help in advance.
Here's my code:
Set LBox2 = ListBox2
myList2Company = LBox2.List
Dim DelCompRow(65000) As String
For r =2 to LastRow
'This is where my problem is: If Range(ColumnD & r).Value NOT IN
myList2Company Then
DeleteThisRow(r)="YES"
End If
Next r
|