Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Compare Cells on Sheet to ListBox Selection

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



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
protect cells after listbox selection Chay Excel Discussion (Misc queries) 3 December 1st 06 11:56 AM
protect cells after listbox selection Chay Excel Discussion (Misc queries) 0 November 30th 06 06:50 PM
protect cells after listbox selection Chay Excel Discussion (Misc queries) 0 November 30th 06 06:49 PM
protect cells after listbox selection JLatham Excel Discussion (Misc queries) 0 November 30th 06 03:00 PM
Capture listbox selection to a cell in a different sheet Marcie Excel Programming 2 September 19th 03 12:15 PM


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

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

About Us

"It's about Microsoft Excel"