There is probably a simple answer (but I'm still taking baby steps)
I have load of data in a spread sheet and I'm trying to populate a combobox with all the site names for a given company (I have multiple instances of both the SiteNames in column A & the CompanyNames in column B)
I can do this to populate the combobox
For SiteNameRange = TotalRows To 3 Step -1
If Range("A" & SiteNameRange) = CBOX_CompanyName.Value Then
CBOX_SiteName.AddItem Range("B" & SiteNameRange)
But this gives every site name for that company, including duplicates. I need to ignor them
So I tried this
For SiteNameRange = TotalRows To 3 Step -1
If Range("A" & SiteNameRange) = CBOX_CompanyName.Value And Range("B" & SiteNameRange) <> Range("B" & SiteNameRange - 1) Then
CBOX_SiteName.AddItem Range("B" & SiteNameRange)
But due to dumb luck (million to one shots happen 9 times out of ten)
The same site name is used on the company I need but also either side! so it skips all the entries. The combo box is empty.
Capture.JPG
Any suggestions on a better solution?
Bookmarks