excel - Compare two columns and find matched rows -


i have written vba code matches 1st column second column , return entries of 1st row not available in second row. given below sample code used in script.

now problem mathcing of columns not happening correctly, matched values coming in output. please me find incorrect?

dim c range, d range dim lastrow1 integer dim lastrow2 integer dim rng1 range, rng2 range, rng3 range  shport_code.activate lastrow1 = cells(rows.count, "b").end(xlup).row lastrow2 = cells(rows.count, "j").end(xlup).row  = 4 lastrow1     set rng1 = shport_code.range("b" & i)      j = 2 lastrow2         set rng2 = shport_code.range("j" & j)         'if rng1.text='         if strcomp(rng1.text, rng2.text, 1) = 0              'rng1.cells("d" & i).value.copy destination:=shport_code.range("j2")             rng1.value = null         'else             'rng1.text.select         end if     next j     if not match         range("j" & range("j" & rows.count).end(xlup).row + 1) = rng1     end if next 

thanks in advance.

renu

sub compare()  dim lastrow1 long, lastrow2 long, integer, j integer, rowa integer,     found integer, x integer  activesheet     lastrow1 = .cells(.rows.count, "b").end(xlup).row *'last row b*     lastrow2 = .cells(.rows.count, "j").end(xlup).row *'last row j* end  rowa = 1 found = 0  = 4 lastrow1     j = 2 lastrow2        x = strcomp(cells(i, 2).value, cells(j, 10).value, 1)        if x = 0 *'if equal*             found = 1 *'value column b in column j*          end if next j  if found = 0 *'if value not in column j*     cells(rowa, 1).value = cells(i, 2).value *'copy value in column a*     rowa = rowa + 1 else     found = 0 *'set found 0 next comparison* end if next  end sub 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -