IF / VLOOKUP with partial text matching from a cell

kkrishna

New Member
Joined
Jan 12, 2011
Messages
16
Dear All,
I was look for a formula if a cell text is matching partially then vlookup from another sheet for matching value.

Cell A 10.253.19.7

in Cell B & C, the formula should have if Cell A 10.253.19.* then vlookup the value from sheet2 and display Subnet mask & gateway respectively.

Sheet2 has table as below:

SubnetSubnet MaskGatewayVLAN
10.15.198.255.255.254.010.15.198.1201
10.253.19.255.255.255.010.253.19.1301

<tbody>
</tbody>






Your assistance on this regards greatly appreciate.

Thank you in advance.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
ABC
1IPSubnet maskGateWay
210.253.19.7=IF(SUBSTITUTE(A2,"10.253.19.","")<>A2,VLOOKUP(C2,Sheet2!A1:D3,2),"")=IF(SUBSTITUTE(A2,"10.253.19.","")<>A2,VLOOKUP(C2,Sheet2!A1:D3,3),"")

<tbody>
</tbody>
 
Upvote 0
Try this. Adjust ranges to suit your data.


Book1
ABCD
1SubnetSubnet MaskGatewayVLAN
210.15.198.255.255.254.010.15.198.1201
310.253.19.255.255.255.010.253.19.1301
Sheet2



Formula in B2 below is copied across and down.


Book1
ABC
1IPSubnet MaskGateway
210.253.19.7255.255.255.010.253.19.1
310.18.255.6Not foundNot found
410.15.198.200255.255.254.010.15.198.1
Sheet1
Cell Formulas
RangeFormula
B2=IFERROR(INDEX(Sheet2!B$2:B$1000,MATCH(SUBSTITUTE(LEFT(SUBSTITUTE($A2,".","."&REPT(" ",9)),30)," ",""),Sheet2!$A$2:$A$1000,0)),"Not found")
 
Upvote 0
louisH & Peter_SSs for your prompt response. I'm so pleased with your kind attention on my request.
 
Upvote 0
Sheet1

<tbody>
</tbody>



1ABCD
2SiteDC2cell not usedcell not used
3Network DetailsIP AddressSubnet MaskGateway
4Primary IP10.14.120.24
5vLAN IDcell not usedcell not used
6Networkcell not usedcell not used

<tbody>
</tbody>

Sheet2

<tbody>
</tbody>



1ABCDEF
2
Subnet

<tbody>
</tbody>
Site

<tbody>
</tbody>
vLAN IDSubnet MaskGatewayNetwork Address
3
10.14.177.

<tbody>
</tbody>
DC 2246255.255.255.192
10.14.177.1

<tbody>
</tbody>
10.14.177.0

<tbody>
</tbody>
4
10.14.27.

<tbody>
</tbody>
DC 2247255.255.255.0
10.14.27.1

<tbody>
</tbody>
10.14.27.0

<tbody>
</tbody>
5
10.14.121.

<tbody>
</tbody>
DC 3147255.255.255.0
10.14.121.3

<tbody>
</tbody>
10.14.121.0

<tbody>
</tbody>
6
10.14.122.

<tbody>
</tbody>
DC 3149255.255.255.0
10.14.122.3

<tbody>
</tbody>
10.14.122.0

<tbody>
</tbody>

<tbody>
</tbody>

these are my 2 sheets that i'm working on.

Along with your formula B2 should also be taken in consideration as we have two sites. If B2 = to DC 2 then if B4 matching 1st 3 octets of sheet2 A3:A100 then sheet1 of C4, D4, B5 & B6 should vlookup the values from sheet2 else not found.

is my query can integrated in below formula?

=IFERROR(INDEX(Sheet2!B$2:B$1000,MATCH(SUBSTITUTE(LEFT(SUBSTITUTE($A2,".","."&REPT(" ",9)),30)," ",""),Sheet2!$A$2:$A$1000,0)),"Not found")

<tbody>
</tbody>
thanks in advance.
 
Upvote 0
For your new sample data ...

1. Do cells A5 and A6 on Sheet1 have anything to do with getting the correct result? If so, what?

2. What are the expected results for that sample data and what cells and what sheet do those results go in?

3. Are there any more complications to be added in after this?
 
Upvote 0
Hi Peter,

A2 to A6 from sheet1 are headers of the results. A5 is vLAN ID associated with that subnet & A6 is network address (ex: 10.14.120.0)
B4 is Manual entry
B5, B6, C4 & D4 should be populated using vlookup or any other integer from sheet2
If I manually input B4 (ex: 10.14.120.24)


on Sheet1, If B2=DC2 & B4="10.14.120." then B5, B6, C4 & D4 fillup automatically from sheet2 by matching the B and A columns of sheet2

no more complication after this.....
 
Upvote 0
See how this goes.

Excel Workbook
ABCDEF
1
2SubnetSitevLAN IDSubnet MaskGatewayNetwork Address
310.14.177.DC 2246255.255.255.19210.14.177.110.14.177.0
410.14.27.DC 2247255.255.255.010.14.27.110.14.27.0
510.14.121.DC 3147255.255.255.010.14.121.310.14.121.0
610.14.122.DC 3149255.255.255.010.14.122.310.14.122.0
Sheet2



Excel Workbook
ABCD
1
2SiteDC 3
3Network DetailsIP AddressSubnet MaskGateway
4Primary IP10.14.121.21255.255.255.010.14.121.3
5vLAN ID147
6Network10.14.121.0
Sheet1
 
Upvote 0

Forum statistics

Threads
1,217,357
Messages
6,136,082
Members
449,990
Latest member
orthodmd

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