Extract single IP address from a string

IanPC

New Member
Joined
Jul 3, 2018
Messages
3
Hello - I have a spreadsheet of URLs, some of which contain IP addresses and some don't. I'm struggling to write an excel formula that will identify the URLs with IP addresses in them, and extract that IP address into another cell. What formula would I paste down column B to achieve this?


[TABLE="width: 500"]
<tbody>[TR]
[TD]URL (column A)[/TD]
[TD]Desired output (column B)[/TD]
[/TR]
[TR]
[TD]http://sample.domain/the/eed/dhgg.html[/TD]
[TD][#Error of some kind][/TD]
[/TR]
[TR]
[TD]http://10.22.88.11/eid/tedld/ed.html[/TD]
[TD]10.22.88.11[/TD]
[/TR]
[TR]
[TD]http://242.25.23.7/ede/vkjd/tt.html[/TD]
[TD]242.25.23.7[/TD]
[/TR]
[TR]
[TD]etc[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Any help gratefully received. Many thanks.
 
Sandy,

Thank you so much for the quick response. After learning about how power query works, I was able to implement this to some success. However, if the source field contains any other numbers in the value, those numbers get extracted as well. Is there a way to eliminate the extra numbers or will I just have to manually remove those from the output?

Example:

sourceIP
programvideoqoe_sentry_sugarhill_86 (172.24.164.155)_TVONE0000NSS_17_E1079-7186172.24.164.155000017107971
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
sorry mate it seems your original example was not representative so post representative example with more than one row
or
use another solutions ;)
 
Upvote 0
My apologies on my original example not being fully representative. Here is an example of about 25 rows:

sourceIP
Gwinnett (3a)_VIPR 172.26.56.1043172.26.56.104
Harmonic - 172.24.100.46172.24.100.46
Imagine BMS 107.8.2.116107.8.2.116
Imagine Encoder – 50.113.193.10950.113.193.109
IMAGINE ENCODER - IMG-DLLATX-ENC04 - 24.174.45.2150424.174.45.215
Imagine Encoder 1.2.10.541.2.10.54
Imagine Encoder 107.8.2.116107.8.2.116
Imagine Encoder 107.8.3.185107.8.3.185
Imagine Encoder 170.8.2.116170.8.2.116
Imagine Encoder 24.174.45.21524.174.45.215
IMAGINE ENCODER 46.9.246.9.2
IMAGINE ENCODER 46.9.246.9.2
Imagine Encoder TWC-MW-04_10 - 107.8.2.1160410107.8.2.116
Imagine Encoder TWC-MW-05 107.8.3.10905107.8.3.109
IMG_c7-01 (107.8.2.116)701107.8.2.116
IN-PS9K_03 172.16.106.29903172.16.106.29
IN-PS9K_03_SGHLGA - 172.26.108.182903172.26.108.182
IN-PS9K_05_SLDCMO 172.28.52.73905172.28.52.73
ION Encoder 172.21.34.13172.21.34.13
ION-4 Encoder - 107.9.92.704107.9.92.70
IVMS 184.152.127.53184.152.127.53
iVMS 184.152.127.53184.152.127.53
IVMS 69.76.65.6769.76.65.67
ivms_KNLC00000NAH_mpeg_8_239.240.0.182000008239.240.0.182
 
Upvote 0
this is IP?
000008239.240.0.182
0410107.8.2.116
903172.26.108.182
this is even not IPv6
 
Upvote 0
You are correct, those ones are not IPs because the query is pulling the other numbers in the value and including it in the output. The value on the left is the source for the query and the output from the query is on the right.

Output from the query:
000008239.240.0.182
0410107.8.2.116
903172.26.108.182

What I need the output from the query to be:

239.240.0.182
107.8.2.116
172.26.108.182
 
Upvote 0
something like this?
sourceTAD
Gwinnett (3a) VIPR 172.26.56.104172.26.56.104
Harmonic - 172.24.100.46172.24.100.46
Imagine BMS 107.8.2.116107.8.2.116
Imagine Encoder – 50.113.193.10950.113.193.109
IMAGINE ENCODER - IMG-DLLATX-ENC04 - 24.174.45.21524.174.45.215
Imagine Encoder 1.2.10.541.2.10.54
Imagine Encoder 107.8.2.116107.8.2.116
Imagine Encoder 107.8.3.185107.8.3.185
Imagine Encoder 170.8.2.116170.8.2.116
Imagine Encoder 24.174.45.21524.174.45.215
IMAGINE ENCODER 46.9.246.9.2
IMAGINE ENCODER 46.9.246.9.2
Imagine Encoder TWC-MW-04 10 - 107.8.2.116107.8.2.116
Imagine Encoder TWC-MW-05 107.8.3.109107.8.3.109
IMG c7-01 (107.8.2.116)(107.8.2.116)
IN-PS9K 03 172.16.106.29172.16.106.29
IN-PS9K 03 SGHLGA - 172.26.108.182172.26.108.182
IN-PS9K 05 SLDCMO 172.28.52.73172.28.52.73
ION Encoder 172.21.34.13172.21.34.13
ION-4 Encoder - 107.9.92.70107.9.92.70
IVMS 184.152.127.53184.152.127.53
iVMS 184.152.127.53184.152.127.53
IVMS 69.76.65.6769.76.65.67
ivms KNLC00000NAH mpeg 8 239.240.0.182239.240.0.182
 
Upvote 0
sure, here is
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Replace = Table.ReplaceValue(Source,"_"," ",Replacer.ReplaceText,{"source"}),
    TAD = Table.AddColumn(Replace, "TAD", each Text.AfterDelimiter([source], " ", {0, RelativePosition.FromEnd}), type text)
in
    TAD
 
Upvote 0
You are welcome & thanks for the feedback
sometimes it's nice to see if someone appreciate your work so hit (y) Like in the posts which have helped you
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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