Multi if Macro or VB code to fill fields based off a column reference?

NGB82KS

Board Regular
Joined
Nov 7, 2019
Messages
82
Office Version
  1. 2016
OK, I've got a spreadsheet with students from all 50 states.
What i'm trying to do is write a macro or a function that checks cell "I" of Table name "ADU" and fills in the state based of a table or code, if that makes sense??
In my Example below, it would lookup the student in row 2, check column I, see the field is BRONX, and would therefore fill in column J with New York.
Anyone know how i could accomplish this? I have to repeat this each month, and doing it all by hand seems...uh.. tedious for 10K plus students.
(Example)
ABCDEFGHIJ
1​
DISPLAYNAMESURNAMEFIRSTNAMEMIGENSTUIDCODEROLECitySTATE
2​
DOE.JOHN.CDOEJOHNC
1234567890​
ASTUBRONX
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Do you have a table with all the cities in one column & their states in another?
 
Upvote 0
Do you have a table with all the cities in one column & their states in another?
I'm still building that but yes, on another tab called lookup, but i stopped because i wasn't sure if a Macro would be better or a table
 
Upvote 0
In that case you can just use a vlookup formula, like
=vlookup(I2,lookup!A$2:B$100,2,0)
 
Upvote 0
In that case you can just use a vlookup formula, like
=vlookup(I2,lookup!A$2:B$100,2,0)
Didn't work, but think that's my table maybe, It looks like this
ABC
1REGION CODESTATECITY
2REGION 1NEW YORKBRONX
 
Upvote 0
Ok, in that case use
=index(lookup!B$2:B$100,match(I2,lookup!C$2:C$100,0))
 
Upvote 0
Ok, in that case use
=index(lookup!B$2:B$100,match(I2,lookup!C$2:C$100,0))
Ok, last one i promise.... It filled in all the states with 1 word but not the two word states. "New York" gives me a #N/A, whereas Ohio gives me Ohio. I tried adding quotes around it but that didnt work. Im trying to look at a google search for exact reference with 2 words while im typing this out as well.
 
Upvote 0
It doesn't matter how many words there are, just as long as the value in I2 is found in col C of the lookup sheet.
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,669
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top