excel - Compare two list of values A and B, if there any value equal to B in the list A -
how compare 2 list of values a
, b
, if there value in b
equals value in list a
, write row number of column a
in front of value in column b
using excel/macro/vba.
use vba:
sub test() dim ws worksheet dim long, j long, k long dim strvalueb string, strvaluea string set ws = activesheet = + 1: j = 0 strvalueb = ws.cells(i, 2).value '2 -> column b if (strvalueb = "") exit j = j + 1 strvaluea = ws.cells(j, 1).value '1 -> column if (strvaluea = "") k = 0 exit elseif (strvalueb = strvaluea) k = j exit end if loop if (k > 0) ws.cells(i, 3).value = k '3-> column c end if loop end sub
Comments
Post a Comment