excel - Finding Values in an array with duplicates values -


i have array of customer names. array full of duplicates, , needs since other data in order row may vary. there no unique identifiers data , need compare data 1 order against rows have customer in array.

i'm having trouble getting loop search rows have customer match.

any appreciated!

dim prodlog string dim orddate variant dim cus string dim owner string dim orddate2 variant dim owner2 string dim logcusts variant logcusts = application.transpose(range("f3", range("f" & rows.count).end(xlup))) dim loglen integer loglen = ubound(logcusts) - lbound(logcusts) dim cust2 variant each cust2 in logcusts     dim custrow integer     custrow = application.match(cust2, logcusts, false) + 1     prodlog = range(cells(custrow, 5), cells(custrow, 5)).value     orddate = range(cells(custrow, 2), cells(custrow, 2)).value     cus = range(cells(custrow, 6), cells(custrow, 6)).value     owner = range(cells(custrow, 7), cells(custrow, 7)).value      databook.activate     logjam.select     orddate2 = range(cells(custrow + 1, 5), cells(custrow + 1, 5)).value     owner2 = range(cells(custrow + 1, 7), cells(custrow + 1, 7)).value      if isempty(orddate)         exit     end if      if isempty(prodlog)         trackbook.activate         masterlog.select         range(cells(custrow, 2), cells(custrow, 17)).clear     else: while cus = cust2         if orddate = orddate2 , owner = owner2             range(cells(custrow, 8), cells(custrow, 8)).value = prodlog         end if     wend end if next cust2 

there couple of ways want do. easiest use dictionary @richard morgan suggests in comment you.

you can loop through array , create new array correct names.

sample code:

private sub uniquearray(olddata variant) collection   set uniquearray = new collection    dim integer   dim j integer   dim foundflag boolean    = 1 olddata.count      foundflag = false     j = + 1 olddata.count        if olddata(i) = olddata(j)         foundflag = true       end if     next j      if not foundflag uniquearray.add olddata(i)   next 

again, think using dictionary better, should work.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -