excel - VBA - How to Retrieves the column number and use it to fill another column? -


how make code work when column number dynamic?

i want code work when of time need work col b , of times col c (the title stay same)?

i tried use function don't think i'm doing right.

public function getcolumn(str string, rng range) integer     getcolumn = application.sheets("sheet1").match("supplier", "poc[#headers]", 0) end function   sub i()     numrows = cells(rows.count, "e").end(xlup).row     = 2 numrows         supplier = cells(i, 16).value          select case supplier             case "edlc", "anc", "edtd", "enc", "apasa p", "ebanrope", "evanc"             getcolumn.value = "zaya"         end select     next  end sub 

try this:

sub test()     dim supplier string     dim poc string     numrows = cells(rows.count, "e").end(xlup).row     = 2 numrows         supplier = cells(i, sheet1.rows(1).find("supplier").column).value         poc = cells(i, sheet1.rows(1).find("poc").column).value         select case supplier             case "ec", "ac", "ed", "enc", "athp", "ebpe", "evanc"             cells(i, sheet1.rows(1).find("poc").column).value = "za"         end select     next end sub 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -