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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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))

[TABLE="width: 411"]
<tbody>[TR]
[TD][/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]123.13.123.xxx[/TD]
[TD]123.13.123.220[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]123.132.132.189 (VPN)[/TD]
[TD]123.132.132.189[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]123.32.32.89 RT[/TD]
[TD]123.32.32.89[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]1.32.432.189 VPN[/TD]
[TD]1.32.432.189[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]D 123.32.32.xxx S 123.32.123.xxx[/TD]
[TD]123.32.32.220[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]10.88.25.xxx[/TD]
[TD]10.88.25.220[/TD]
[/TR]
</tbody>[/TABLE]
 
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,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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