Having issues with index match

Knockoutpie

Board Regular
Joined
Sep 10, 2018
Messages
116
Office Version
  1. 365
Platform
  1. Windows
Can anyone help on this? I'm trying to pull the city name and province from an address based off a range on sheet two, but I can't seem to get this to work..
The formulas will go in the City and province columns

Test.xlsx
ABCDEF
1ADDRESS_ENGCITYCOUNTRYSTATEPOSTAL_CODEPROVINCE
2295 YANGGUANG RD,NANGANG TOWN,KUNSHANCN215300
33F-10 BUILDING, ZHONGYUNTAI SCIENCE & INDUSTRIAL PARK, TANGTOU 1ST ROAD SHIYAN TOWN, BAOAN DISTRICT, SHENZHEN, GUANGDONG, CHINACN518108
43RD FLOOR, NO. 10 BUILDING, ZHONGYUNTAI SCIENCE IND. PARK, TANGTOU 1ST ROAD SHIYAN TOWN, BAOAN DISTRICT, SHENZHEN, GUANGDONG, CHINACN518108
57 FLOOR NO.6 BINLANG ROAD, FUTIAN FREE TRADE ZONE ,SHENZHENCN
6B1-B3 2F,NO.1135 XIANGYANG ROAD,MINHANGDISTRICT, SHANGHAI 201108,CHINACN201108
7B1-B3 2F,NO.1135 XIANGYANG ROAD,MINHANGDISTRICT, SHANGHAI 201108,CHINACN201108
8NO.2588 SOUTH LIANHUA ROAD,MIN HANG DISTRICT,SHANGHAI,201100,P.R.CCN201100
9NO.2588 SOUTH LIANHUA ROAD,MIN HANG DISTRICT,SHANGHAI,201100,P.R.CCN201100
10NO.2588 SOUTH LIANHUA ROAD,MIN HANG DISTRICT,SHANGHAI,201100,P.R.CCN201100
11NO.2588 SOUTH LIANHUA ROAD,MIN HANG DISTRICT,SHANGHAI,201100,P.R.CCN201100
12NO.2 TAIGU RD WAIGAOQIAO FREE TRADA ZONE,SHANGHAI,P.R.C. AITGCN
13NO.2 TAIGU RD WAIGAOQIAO FREE TRADA ZONE,SHANGHAI,P.R.C. PECGCN
14NO.2 TAIGU RD WAIGAOQIAO FREE TRADA ZONE,SHANGHAI,P.R.C. WPIGCN
15NO.2 TAIGU RD WAIGAOQIAO FREE TRADA ZONE,SHANGHAI.CN
16NO.8 DATONG ROAD,NEW DISTRICT, SUZHOU.CHINACN
17NO.8 DATONG ROAD,NEW DISTRICT, SUZHOU.CHINA PECGCN
18GROUND FLOOR SOUTH PART NO 161 RIJING ROAD CHINA (SHANGHAI)CN
19KUNSHAN XINING BONDED WAREHOUSE CO.,LTD 295 YANGGUANG RD,NANGANG TOWN,KUNSHANCN
20NAN ZHA 5TH INDUSTRIAL ZONE HUMEN TOWN,DONG GUAN CITY DONG PROVENCE PEOPLES REPUBLIC OF CHINACN
21NO. 2588 SOUTH LIANHUA ROAD, MIN HANG DISTRICT, SHANGHAI 201100 P.R. CHINA 310000CN201100
22NO. 6 JINCHANG ROAD, HENAN INDUSTRIAL ZONE JINXIA, CHANGAN DONGGUAN, CHINACN
23NO.1,NO.168 WEIHUA ROAD,PUDONG,SHANGHAI,CHINACN
24NO.200 4/A FUTE ROAD(E),WAI GAO QIAO FREE TRADE ZONECN
25NO.200 4/A FUTE ROAD(E),WAI GAO QIAO FREE TRADE ZONECN
26NO.200 NORTH.FUTE RD,WAI GAO QIAO FREE TRADE ZONE,PUDONG,SHANGHAI,CHINA CN
27O. 2588 SOUTH LIANHUA ROAD, MIN HANG DISTRICT,CN200000
Sheet1


Test.xlsx
ABCD
1Provinces in ChinaProvinces in China AbbreviationCity
2
3AnhuiAHBeijing
4BeijingBJChongqing
5ChongqingCQShanghai
6FujianFJTianjin
7GansuGSHong Kong
8GuangdongGDMacau
9Guangxi ZhuangGXAnqing
10GuizhouGZBengbu
11HainanHIBozhou
12HebeiHEChaohu
13HeilongjiangHLChizhou
14HenanHAChuzhou
15HubeiHBFuyang
16HunanHNHefei
17JiangsuJSHuaibei
18JiangxiJXHuainan
19JilinJLHuangshan
20LiaoningLNJieshou
21Nei Mongol (Inner Mongolia)NMLu'an
22Ningxia HuiNXMa'anshan
23QinghaiQHMingguang
24ShandongSDNingguo
25ShanghaiSHSuzhou
26ShanxiSXTianchang
27ShaanxiSNTongcheng
28SichuanSCTongling
29TianjinTJWuhu
30Xinjiang UygurXJXuancheng
31XizangXZChangle
32YunnanYNFu'an
33ZhejiangZJFuding
Sheet2
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I can only think of one way, loop through sheet 2 to find the items in sheet1

Little prep work.

Sheet2 column I use this formula.
1658258433698.png


Then use this code to filter sheet1 and place the data in the correct columns.

VBA Code:
Sub get_Info()
    Dim ws As Worksheet, sh As Worksheet
    Dim rng As Range, c As Range, fRng As Range
    Set ws = Sheets("Sheet2")
    Set sh = Sheets("Sheet1")

    With ws
        Set rng = .Range("I2:I" & .Cells(.Rows.Count, "I").End(xlUp).Row)
    End With
    With sh
        Application.ScreenUpdating = False
        For Each c In rng.Cells
            If c > 0 Then
                .Range("$A$1").AutoFilter Field:=1, Criteria1:="=*" & c.Offset(, -8) & "*", Operator:=xlAnd
                Set fRng = .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
                fRng.SpecialCells(xlCellTypeVisible).Offset(, 1) = c.Offset(, -5)
                fRng.SpecialCells(xlCellTypeVisible).Offset(, 5) = c.Offset(, -7)
            End If
        Next
        If .AutoFilterMode = True Then .AutoFilterMode = False
    End With



End Sub
 
Upvote 0

Forum statistics

Threads
1,215,370
Messages
6,124,526
Members
449,169
Latest member
mm424

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