If/Then Excel Formula Needed?

marriedmanmike

New Member
Joined
May 11, 2021
Messages
4
Office Version
  1. 365
Platform
  1. MacOS
Big Picture: I have a 700 names and cell numbers I need to sort by state. I have all area codes in a separate tab, column A and their state in B. I'd like Excel to read the column of cell phones, find it's match then add the label to the next column.

Tab 1= List
Tab 2: AreaCode
Names: List, Column F
Cell Phones: List, Column I
Area Codes: AreaCode, Column A
States: AreaCode, Column B

Is this possible?
What formula would I enter in "List, Column I" to have it read and auto enter the corresponding state label?
Thank you for any help!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Can you post some sample data from both sheets.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Can you post some sample data from both sheets.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Hm, problem is it is individual's names and cell phones... Let me see if I can create a sample sheet with made up stuff.
 
Upvote 0
Excel Test File.xlsx
ABCDEF
1NameCell PhoneState (NEED LABEL)CORRECT ANSWERArea Code State or Territory
2Joe(207) 234-5678Maine207Maine
3Bob(208) 234-5678Idaho208Idaho
4Joe(209) 234-5678California209California
5Bob(210) 234-5678Texas210Texas
6Joe(212) 234-5678New York212New York
7Bob(213) 234-5678California213California
8Joe(214) 234-5678Texas214Texas
9Bob(215) 234-5678Pennsylvania215Pennsylvania
10Joe(216) 234-5678Ohio216Ohio
11Bob(217) 234-5678Illinois217Illinois
12Joe(218) 234-5678Minnesota218Minnesota
13Bob(219) 234-5678Indiana219Indiana
14Joe(224) 234-5678Illinois224Illinois
15Bob(225) 234-5678Louisiana225Louisiana
16Joe(228) 234-5678Mississippi228Mississippi
List


Ok, put all the pertinent info in a mini sheet. If formula is correct, Column C will match Column D. So, need to match first 3 digits of cells in Column B with anything from Column E. That better?
 
Upvote 0
Welcome to the Board!

Here is one way, assuming that column B is Text and not formatted numbers.
Put this formula in cell C2 and copy down for all rows:
Excel Formula:
=VLOOKUP(MID(B2,2,3)+0,E:F,2,0)

If column B is formatted numbers, try this version:
Excel Formula:
=VLOOKUP(LEFT(B2,3)+0,E:F,2,0)
 
Upvote 0
Solution
Ok, after some formatting of the data (removing spaces, dashes and parenthesis as some had them some were just 10 digits), the second formula works. Thanks!
 
Upvote 0
You are welcome.
Glad I was able to help!

:)
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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