简体   繁体   中英

Excel VBA: vLookup on a specific column in a Named Table and replacing value if it matches with multiple criteria and wildcard

I'd like to create a macro that will take the name of the resource and do a vLookup (or similar action) on another table to find the matching resource manager's info, then replace the NULL manager name and email address in the first table with the manager info that corresponds to that Resource. The end goal is to complete my table with the Generic Resource's manager and their email address.

I have a table on Sheet1 named "Resources":

"Resources" table

I also have a table on Sheet2 named "ManagerLookup":

"ManagerLookup" table

How can I loop through each Resource Name in my table to match the resources up with their correct manager? I'm only looking to replace the manager fields for which I have a match on the Resource Name. I can't only perform vlookup on rows with a "NULL" Manager name, since my data does not only use "NULL" for missing manager names (sometimes it's different).

I've searched for hours and can't find anything, but I need a clean way to do this. Also worth noting is that the "Resources" table doesn't ever get larger than about 500 rows so processing time is not a factor here. I'm using Excel 2016.

如果前两个字母对于经理是唯一的(例如您的示例),请从“经理”表中删除#号,并在资源表中使用以下公式:

=IFERROR(VLOOKUP(LEFT(A2,2)&"*",Sheet2!A:B,2,FALSE),"Not found")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM