Excel - Cross Reference - Different Sheets - excel

I have 3 different sheets for the excel document -- 1. County Lookup by Zip Code, 2. County Recording Fees, 3. ZipCode
What I a trying to achieve is the user will enter the Zipcode on the sheet 'County Lookup by Zipcode' and then it will look for the county name on the 'ZipCode' sheet and then it will grab the Recording Fee off the sheet name 'County Recoding Fees'
Issue is that counties in different states in the US have the same name so it is pulling in the wrong fee amount.
I've tried VLOOKUP with no luck.
Link to sheet --
https://urldefense.com/v3/__https://docs.google.com/file/d/1LwvPLmgL9DUT0aopnuNMYJTzksHT8Xn_/edit?usp=docslist_api&filetype=msexcel__;!!KurxxnpmNnI!ViU4pth0-f26aMXJFfiBzD8ktnisXsL7PC_vfDdWCaLx832109gGj0bx2v8jq6UDv-Eqfg$

The data on the the County Recording Fees tab seems incomplete. For example, there is no data for Los Angeles County. Maybe that is ok?
Also the County Recording Fees seems to have data rows for each city and town in a given county. For example, in the case of zip code 6042, the count_fips is 9003. There are 31 rows on the County Recording Fees with a value of 09003. Maybe that is is ok, too?
All that said, you can use nested XLOOKUPs to find the data you want.
I put my formulas in row A4 on the County Lookup by Zipcode tab.
In A4, 6042
In B4, =XLOOKUP(A4,ZipCode!A2:A33122,ZipCode!L2:L33122,"Not Found")
In C4, =XLOOKUP(A4,ZipCode!A2:A33122,ZipCode!E2:E33122,"Not Found")
In D4,
=XLOOKUP(
TEXT(XLOOKUP(A4,ZipCode!A2:A33122,ZipCode!K2:K33122,"Not Found"),"00000"),
'County Recording Fees'!C2:C3204,'County Recording Fees'!E2:E3204
)
The first look up grabs the value in the 'county_fips' column on the Zip Code tab and converts the value to text. Then that value is used to look up the 'FIPS Code' on the County Recording Fees tab in column C, the return value is the 'FirstPageFee' in Column E.
in E4,
=XLOOKUP(
TEXT(XLOOKUP(A4,ZipCode!A2:A33122,ZipCode!K2:K33122,"Not Found"),"00000"),
'County Recording Fees'!C2:C3204,'County Recording Fees'!G2:G3204
)

Related

How to generate invoice numbers with a combination of customer codes without duplicates and sequentially with VBA

Dear All Master,
How to generate invoice numbers with a combination of customer codes without duplicates and sequentially with VBA.
so the position in "C2" is the customer code.
So the "serial" will change continuously in order with the customer code. Does it need invoice numbers stored in their own sheets so that they make it easier for duplicates and sequential to occur? if necessary how?. Please recommend the best solution
in "C4" is the combination invoice number.
JS : COMPANY NAME
12 : MONTH
22 : 2 DIGIT YEAR
XX : CUSTOMER CODE
001 : SERIAL
EXAMPLE
JS-12-22-10-001
JS-12-22-10-002
JS-12-22-11-001
JS-12-22-11-002
Sub generatenumberinvoice()
Sheet1.Range("c3").Value = Sheet1.Range("c3").Value + 1
End Sub
This is not directly help you, but maybe you can have a look and modify it according to your case.
Make a new workbook
Rename Sheet1 into TABLE, Sheet2 into DATA, Sheet3 into FormInput
Type on each sheet exactly like in the picture below. For the time being, ignore the INPUT button which seen in the image of sheet FormInput
In the Name Manager, create a named range CustID which refers to:=OFFSET(TABLE!$A$1,0,0,COUNTA(TABLE!$A:$A),2)
Create another named range : data which refers to: =OFFSET(DATA!$A$1,0,0,COUNTA(DATA!$A:$A),4)
Create another named range : trans which refers to : =OFFSET(FormInput!$A$6,0,0,COUNTA(FormInput!$A:$A)-4,1)
Finally, copy the formula below and paste it to cell B3 of sheet FormInput =IF(COUNTIF(INDEX(data,,3),"*JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"*")<>0,"JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-"&TEXT(AGGREGATE(14,6,RIGHT(INDEX(data,,3),3)/(LEFT(INDEX(data,,3),12)="JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-"),1)+1,"000"),"JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-001")
Try to type aaa (the name of customer) in cell B2 sheet FormInput. If everything above done correctly, cell B3 will show JS-22-12-10-001. Type bbb then it show JS-22-12-11-001, type ccc then it show JS-22-12-12-001. The last 3 characters always show 001 (which means this is the first invoice number of Dec-22 for whatever id), because there is no data in sheet DATA. Hence it just show 22-12 depends on the date seen in cell B1, and -10 or -11 or -12 depends on the name of the customer seen in cell B2.
Try to change the date to something like 21-nov-22. Cell B3 will show 22-11 and the CustID depends on the name seen in cell B2, and the number always show "001". Play around by changing the date of different month and change the name (aaa or bbb or ccc) so you understand thoroughly how it works.
Now, fill data in sheets DATA exactly like the image below
Back in FormInput, fill the date with Nov-22 month and fill the cust name with aaa, cell B3 will show the next invoice number: JS-22-11-10-006 because the formula read the data that the last number for id 10 in Nov-22 is JS-22-11-10-005, so the formula add 1 to the serial number in cell B3 for id 10 (customer aaa in this case).
Still in November date, type bbb for cust name. It will show JS-22-11-11-001 in cell B3 because there is no data for id 11 of Nov-22. So this is the first invoice number of Nov-22 for id 11 (customer bbb in this case).
Now change the date to December date, then type aaa for cust name. Cell B3 will show the next invoice number for id 10 in Dec-22 is JS-22-12-10-002, because the formula see that the last number in the data for id 10 of Dec-22 is "001".
Still in December date,
type ccc for cust name. Cell B3 will show JS-22-12-12-004.
type bbb for cust name. Cell B3 will show JS-22-12-11-001 which means this is the first invoice number for id 11 in Dec-22.
Play around by filling a different invoice number in sheet DATA then fill the date and the name of the cust in sheet InputForm.
The INPUT button seen in InputForm is a vba code to input the data seen in InputForm into sheet DATA. But this is another case, and if you want to know it, I think you'd better open another question.
Thank you.
Thanks to Mr. Peter_SSs, because I get the formula for cell B3 from him in this link

Splitting addresses into columns in Excel

I need help splitting addresses into columns in Excel.
Addresses in COLUMN A are written like:
601 W Houston St Abbott, TX 76621 United States
13498 US 301 South Riverview, FL 33578 United States
COLUMN B is actually a helper column. It contains only the city names from COLUMN A. My idea was to somehow match COLUMN B with COLUMN A and then all matches move to another column. That would separate City from the Address.State, Zip and Country I can use "split text to columns" since "comma" is delimiter. But I need help splitting address and the city.
There is a "comma" right after the city name, but some cities has more than one word in city name.
What I need to do is split the addresses like it's highlighted in green in the image below.
What is the best way to do that in Excel? What would be the formula for that?
We can use a quirk of LOOKUP to get this working.
=LOOKUP(1E+99,FIND(B$2:B$100,A2),B$2:B$100) in D2 will return the city based on searching for matches in column B. Note that this will need the full range of column B specified to be filled.
Then we can put =LEFT(A2,FIND(D2,A2)-2) in C2 to get the first part of the address.
The rest is easy if we can assume that the state, Zip and country are of constant length (if you've got any addressses outside the US then you'll need to alter this):
=LEFT(RIGHT(A2,22),3) in E2
=LEFT(RIGHT(A2,19),5) in F2
=RIGHT(A2,13) in G2
Since you already have City in Col B, just replace the city in A
D2 =SUBSTITUTE(A2,C2,"")
Column C Paste special values in Col C
Split Column C using comma.
Then split the Column D using "space". Assuming you have all records in US, you can add the country to all rows if required.
EDIT
I missed that the city name in the row does not correspond to the address. To match the city from the Master, you can use this array formula:
C2 =INDEX(B:B,MATCH(1,MATCH(""&$B:$B&"",A2,0),0))
Array formula must be confirmed with Ctrl-Shift-Enter.
However, this will find the first match. If you have cities Foster & Foster City in your master, Foster City wlll never be matched. So, sort the cities in descending order of length.
Once you have the City name matched you can follow the steps I gave earlier. Note that I have adjusted the formula to take into account the city name that has been matched by this new formula.
So, it is possible to get it done with the formula. It may not be the best way, but I got what I needed.
I've added a new sheet and named it "cities"
I moved the city list from sheet 1 to COL A in sheet "cities"
In sheet 1, B1 = =INDEX(cities!$A$1:$A$10000;LOOKUP(99^99;MATCH(RIGHT(TRIM(LEFT(SUBSTITUTE(A2;",";REPT(" ";255));255));ROW($A$1:$A$100));cities!$A$1:$A$10000;0)))
Then I've simply use SUBSTITUTE to remove city names from column A in Sheet 1: C1==SUBSTITUTE(A1, B1, "")
And that's it!

Compare and match the columns in Excel

Column "A" is static and can't be change. I have to re-arrange column B to match it with column A.
Column "C" is a part of column B and should be re-arranged accordingly. See the end result.
A B C
SGK LSP BAL BHARATI PUBLIC SCHOOL
RNG KQN BAL BHAVAN INTERNATIONAL SCHOOL
LSP SGK BASAVA INTERNATIONAL SCHOOL
KQN LAK BGS INTERNATIONAL SCHOOL
QEH HDY BRAIN INTERNATIONAL SCHOOL
QEH BRAIN INTERNATIONAL SCHOOL
RNG BRAIN INTERNATIONAL SCHOOL
I want the end result to be in this format:
A B C
SGK SGK BASAVA INTERNATIONAL SCHOOL
RNG RNG BRAIN INTERNATIONAL SCHOOL
LSP LSP BAL BHARATI PUBLIC SCHOOL
KQN KQN BAL BHAVAN INTERNATIONAL SCHOOL
QEH QEH BRAIN INTERNATIONAL SCHOOL
HDY BRAIN INTERNATIONAL SCHOOL
LAK BGS INTERNATIONAL SCHOOL
What would be the formula for this? I have a thousand such files.
If I understand you properly, to solve this problem you will need to use the VLookup function.
Create a new spreadsheet
Copy the headers over
Copy all of column A
The formula for cell B2 would be =A2
The formula for cell C2 would be =VLOOKUP(B2, Sheet1!$B:$C, 2, false)
Create a custom list from your A column, then sort B:C according to that.
To create a custom list go to Excel > Options > Advanced > General > Edit Custom Lists... > select as much of Column A as required, Import, OK, OK.
This is a application level setting, so available 'until further notice'.
Assuming your data is as in the image below and you want result in Column H and Column I.
Enter the following formula in cell H2:
=IFERROR(VLOOKUP($A2,$B$2:$C$20,1,FALSE),IFERROR(INDEX($B$2:$B$20,MATCH(0,IFERROR(MATCH($B$2:$B$20,$A$2:$A$20,0),COUNTIF($H$1:$H1,$B$2:$B$20)),0)),""))
This is an array formula so commit it by pressing Ctrl+Shift+Enter.
Then in cell I2, enterthe following formula:
=IFERROR(VLOOKUP($A2,$B$2:$C$20,2,FALSE),IFERROR(INDEX($C$2:$C$20,MATCH(0,IFERROR(MATCH($B$2:$B$20,$A$2:$A$20,0),COUNTIF($H$1:$H1,$B$2:$B$20)),0)),""))
Again, this is an array formula so commit it by pressing Ctrl+Shift+Enter.
NOTE:- Result will not display names that are in Column A but not in Column B.
Second part of the formula is taken from here.

Excel Index Partial match

I have Sheet1 with column A listing every single country in alphabetical order..
A
1 Afghanistan<
2 Albania
3 Algeria
4 American Samoa
5 Andorra
----------
228 United Kingdom
229 United States
etc
I have Sheet2 column A with empty cells with adjacent cells in column B listing address details
A B
1 empty cell Unit 3, Road;London, United Kingdom
2 empty cell Building 1, Road, TX, United States
3 empty cell 8th floor, Business Park, India 1234
etc
What I would like to know is how can I obtain the country within the address details in sheet2 column B and place them in Sheet2 column A, based on a match on the list of countries in Sheet1 column A.
Part of the problem is there is no coherent method as to how to country is placed within the address; could be at the end or in the middle of the address.
I have tried various index match formulas with no luck
any help would be appreciated.
I tried it with the reference table being in A1:B7, and lookups being A10:B10 onwards down. The formula is for these cells. You can adjust it for Sheet1/2!.
Assuming your data is in B10 onwards, and your reference data was in B1:B7, you can write this formula in A10 =INDEX($B$1:$B$7,MAX(IF(ISERROR(FIND($B$1:$B$7,B10)),-1,1)*(ROW($B$1:$B$7)-ROW($B$1)+1))). This is an array formula, so please hit Ctrl+Shift+Enter for excel to read it as an array formula.
(In the screenshot, I have pasted the table in A10:B12 as values only in D10:E12)
Text to Columns with a comma delimiter

Formula to Get data for a specific date

Date Time Country Desc
16/04/14 8.30 am India abcd
16/04/14 9.30 am India pqrs
17/04/14 9.30 am India xyz
17/04/14 10.30 am India abcd
I wish to get all the data of 16/04/14 in another sheet using formula. Vlookup takes only the first row data as reference is 16/04/14. Is there any other way to get data.
Try this then:
Assuming you have this data in Sheet1:
And you want to get all matches of dates in Sheet2 like this:
What you need to do is use this formula:
=IFERROR(INDEX(Sheet1!A$1:A$5,SMALL((IF(Sheet1!$A$1:$A$5=$E$1,ROW(Sheet1!A$1:A$5))),ROW($A1)),1),"")
Above is an Array Formula entered by pressing Ctrl+Shift+Enter.
Enter it in A2 then copy on the remaining cells.
For our example, I copied it until Row 10 (A2:D10).
Then you just need to type in the value you want displayed in E1 as shown in the picture.
Then all the columns will populate with the data that you need.
Hope this helps.
Important: The ranges in the formula needs to be adjusted to suit your needs.

Resources