Extract IP Address from text/string

Snypa

New Member
Joined
Nov 1, 2013
Messages
45
Hello,

I have a vlookup that will return values such as the following:

1. "123.123.123.xxx"
2. "123.32.32.89 (VPN)"
3. "123.32.32.89 RT"
4. "123.32.32.89 VPN"
5. "D 123.32.32.xxx S 123.32.123.xxx"

I currently have the following formula which only works in the first instance: =LEFT(C7,FIND(".",C7,FIND(".",C7,FIND(".",C7)+1)+1)-1)&".220"

What I need is a formula that will extract either the whole IP address in instances 2, 3, 4 or the first 3 octets in the final instance that would also work in the first instance (only need the first IP address).
 
That works when I test it on a new worksheet but when I use it within my Spread sheet, I am getting a #Value error. Any idea why, such a number or text format?

Looking at the error its the mid statement that gives the error. It looks correct though:

mid("10.88.25.xxx", 0, 255)

That's because you now have a 2 leading digit...

Again, please show MORE data samples.
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Okay, I figured out the issue. It expects the first octet to have 3 characters, which is not always the case. Is there anyway this can be fixed in the formula? It is happy to work with 2 or 3 characters in the 2nd and 3rd octets.
 
Upvote 0
Hi,

Try this : 3 red space

D7 =TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(LEFT(C7,FIND("*",SUBSTITUTE(C7,".","*",{3}))+3),"xxx",220)," "," "),15))

CD
7123.13.123.xxx123.13.123.220
8123.132.132.189 (VPN)123.132.132.189
9123.32.32.89 RT123.32.32.89
101.32.432.189 VPN1.32.432.189
11D 123.32.32.xxx S 123.32.123.xxx123.32.32.220
1210.88.25.xxx10.88.25.220

<tbody>
</tbody>
 
Last edited:
Upvote 0
You're welcome.

Hopefully, this will cover all scenarios:


Book1
ABC
1123.123.123.xxx123.123.123.220
2123.32.32.89 (VPN)123.32.32.89
3123.32.32.89 RT123.32.32.89
4123.32.32.89 VPN123.32.32.89
5D 123.32.32.xxx S 123.32.123.xxx123.32.32.220
610.88.25.xxx10.88.25.220
71.1.111.xxx1.1.111.220
8D 1.11.1111.11.111
9D 12.23.333.xxx12.23.333.220
Sheet33
Cell Formulas
RangeFormula
C1=TRIM(LEFT(SUBSTITUTE(SUBSTITUTE(MID(A1,IF(MID(A1,2,1)=" ",3,1),255),"xxx",220)," ",REPT(" ",100)),100))
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

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