Hi, I am having a little issue with my code.
Code:
cbx3 and cbx4 are comboboxes, cbx4 is populated from the selection made in cbx3.Private Sub cbx3_Change() cbx4.Clear cbx4.Text = "Select Material" Dim cbx3rng As Range, firstfound As String With Worksheets(1).Columns(1) Set cbx3rng = .Find(cbx3.Value, Range("A1"), MatchCase:=False) If Not cbx3rng Is Nothing Then firstfound = cbx3rng.Address cbx4.AddItem cbx3rng.Offset(0, 1).Value Do Set cbx3rng = .FindNext(cbx3rng) cbx4.AddItem cbx3rng.Offset(0, 1).Value Loop Until cbx3rng.Address <= firstfound Or cbx3rng Is Nothing End If End With End Sub
My table, basically, is a list of parts (from 1 to 17) that have different materials associated with them. Part1 has 15 materials, part2 has 10, etc.
The issue is that when my Find arrives at Cell "A10", it stops and returns the value of A10 as the last cell of the find, but in my table it should go up to A15.
Changing the Range in red to Range("A10") solves this issue.
Going from single digit to double digit seems like the problem.
Also, the same thing happens for a search where the cells in column A containing cbx4.Value are between 90 and 110, the search stop at 100. It seems that going from double digits to triple digits also makes an error.
Changing the Range in red to Range("A100") solves this issue, but not the first one (going from single to double digits).
Anyone has any experience with this problem ?
Thanks,
Alexis
Last edited by alsega; 02-13-2012 at 10:50 AM.
I think you need to close your loop withLoop while cbx3rng.Address <> firstfound
Change this:
to thisLoop Until cbx3rng.Address <= firstfound Or cbx3rng Is Nothing
Loop While cbx3rng.Address <> firstfound
Good luck.
Hi guys, thanks for the quit answers.
Loop while cbx3rng.Address <> firstfound
That does work like a charm ! Simple solutions always work the best.
Thanks alot!
Alexis
Please don't forget to mark the thread solved.
Good luck.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks