Nested For Loops to Look at 2 ListBoxs in VBA UserForm
Hi All
Happy New Year. I'm attempting to compare items from one listbox with those in another listbox (both on the same userform).
I appear to be using the wrong approach because ListBoxA stops passing values when I introduce a nested ForLoop to look at ListBoxB. Code as follows:
For i = 0 To myForm.ListBoxA.ListCount - 1 myForm.ListBoxA.ListIndex = i AItem = myForm.ListBoxA.Value MsgBox ("List A: " & AItem)' For j = 0 To myForm.ListBoxB.ListCount - 1' Next jNext i
I tried changing the i to a 1 for testing purposes (there are 3 items in my list so this should have worked... I have not uncommented the other code.
Cheers,
DrTribos
ASKER
Do I need to reDim AItem? Currently string, also tried DataObject... really I'm just guessing :-(
IrogSinta
Sorry, I just noticed you're doing this in MS Word. I assumed you were in Access. Can you upload a copy of this document? Just remove any private information first.
Will clean for upload. The other thing I noticed is that if I click in the listbox before running my macro it works perfectly. BUT if I don't click (which would be easily anticipated for this application) it does not work... is there a way to give focus to the list - that might help too...
BTW sorry for reply lag... for some reason my EE emails are not popping up :-(
Compile Error:
Method or data member not found
I tried changing the i to a 1 for testing purposes (there are 3 items in my list so this should have worked... I have not uncommented the other code.
Cheers,