简体   繁体   中英

Auto populate Excel field based on Drop down value in another column

I have an excel sheet with few columns. One of the columns is a drop down based on a handful of values that I added. However, For each drop down value there is a matching account number which I would like auto populated once the drop down value is selected. Column D has the drop down and the drop down values and accounts are in BR5: BS38 and Would like the account to be populated in column E automatically everytime a drop down values is chosen.

Code I am using, however, it doesnt populate automatically, I have to copy the formula down and when I copy it down, if nothing is chosen in the drop down it will se #N/A.

=VLOOKUP(D5:D38,$BR$3:$BS$38,2,0)

Without VBA the formula will have to be copied down.

An easy work around would be to nest your vlookup in an iferror function and have it already populated in a set range of rows. So if you know the user will never type more than 1000 rows have the formula already there.

Your new formula would look like this. The only thing this does is remove the #N/A. Not sure why you specified a range in your vloopup lookup value, so this formula only picks the first cell in that range.

=IFERROR(VLOOKUP(D5,$BR$3:$BS$38,2,0), "")

If you would like some error checking, not sure if your drop down allows foreign values, you can use a formula like this

=IF(D5="","",IFERROR(VLOOKUP(D5,$BR$3:$BS$38,2,0),"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