vba - Matching excel value of column A and E to a name in column B and D -


basically have huge excel file numbers assign name (i start name unknown)

     |    b 123456 | unknown   456875 | unknown2 

assign sequenced number different values of rows.
if column a2 = column e25, replace value of d25 unknown2

does make sense?

i looking macro automatically

it's clear enough me understand you...

you have numbers in column , d - each number want specific name.

the names should listed in column b (for numbers in a) , column e (for numbers in d).

if there numbers in in d, too, these numbers share same name.

try code:

sub test()  dim rng range dim long, j long, k long, l long dim firstaddress string, foundaddress string  = 1 rows.count - 1      if isempty(cells(i, 1).value) exit  next  j = 1 rows.count - 1      if isempty(cells(j, 4).value) exit  next j  set rng = range("a1:a" & & ", d1:d" & j)  l = 1  k = 1 + j      if k <          firstaddress = rng.find(cells(l, 1).value, lookat:=xlwhole, matchcase:=true).address         foundaddress = firstaddress          if cells(l, 2).value = ""              until firstaddress = ""                  cells(range(foundaddress).row, range(foundaddress).column + 1) = "name" & k                  foundaddress = rng.find(cells(l, 1).value, range(foundaddress), lookat:=xlwhole, matchcase:=true).address                  if foundaddress = firstaddress _                     exit              loop          end if      else          if k = _             l = 1          firstaddress = rng.find(cells(l, 4).value, lookat:=xlwhole, matchcase:=true).address         foundaddress = firstaddress          if cells(l, 5).value = ""              until firstaddress = ""                  cells(range(foundaddress).row, range(foundaddress).column + 1) = "name" & k                  foundaddress = rng.find(cells(l, 4).value, range(foundaddress), lookat:=xlwhole, matchcase:=true).address                  if foundaddress = firstaddress _                     exit              loop          end if          if l = j - 1 _             exit sub      end if      l = l + 1  next k  end sub 

here pictures - want?

before

after


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -