troubleshooting Question

Nested For Loops to Look at 2 ListBoxs in VBA UserForm

Avatar of DrTribos
DrTribosFlag for Australia asked on
Microsoft Word
9 Comments3 Solutions383 ViewsLast Modified:
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 j
Next i

As soon as I uncomment the inner For-Next the MsgBox will not display AItem

This is most alarming!

Cheers, S
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros