Excel IP Address Parse and Search

birdman91

New Member
Joined
Aug 9, 2015
Messages
16
Hello All,

I've been lurking through these forums in search of a result for my problem and could not find a complete solution. So I made an account to see if someone out there can help me out.

I have a word document that I get regularly that contains hundreds of IP address along with text in this general Format:

We are looking at these IP address 122.122.121.123 and 12.13.51.123 with special attention to the following:
A. 187.213.123.1
B. 232.123.54.012
C. etc
D. etc...

1. 124.123.123.123
2. 18.12.51.32
3. etc....

Right now I am copying and pasting the word document into excel and running the following

Code:
Sub removechar()
Dim rng as range
Dim workrng as range
on error resume next
xtitleid = "IPaddress"
set workrng = application.selection
set workrng = application.inputbox("range", xtitleid, working.address, type:=8)
For Each rng in workrng
     xout = ""
     for i = 1 to len(rng.value)
            xtemp = mid(rng.value, i, 1)
            if xtemp like "[0-9.]" then
                xstr = xtemp
            else
                xstr = ""
            end if 
            xout = xout & xstr
      next i 
      rng.value = xout
next
end sub

As you can see it is simply removing everything that is not a number or a period. So as you can imagine I get the following outputs.

122.122.121.12312.13.51.123
.187.213.123.1
.232.123.54.012
.
....

1.124.123.123.123
2.18.12.51.32
3.....

With this I can go through and manually clean up the rows but when I get thousands of rows sometimes it can get tedious. The obvious output I'd like to see is... which deletes empty rows as well.
122.122.121.12
312.13.51.123
187.213.123.1
232.123.54.012
124.123.123.123
18.12.51.32

The next step is where it gets even trickier. I want to be able to cross check those IPs versus a master list to check for duplicates. Now I know I can use conditional formatting to easily highlight duplicates but I also need to check against IP ranges in this format.

2.0.0.02.255.255.255
15.42.32.015.42.40.255
145.132.123.0145.140.255.255

<tbody>
</tbody>


My ideal output and final check workbook, if even possible, would look something like this with the Check IP denoting if it is a duplicate value by highlighting itself or other visual queue.

<tbody>
</tbody>
Check IPsMaster Single IP listMaster IP Range ListMaster IP Range list
122.122.121.127.0.0.02.0.0.02.255.255.255
312.13.51.1237.0.0.115.42.32.015.42.40.255
187.213.123.17.0.0.2145.132.123.0145.140.255.255
232.123.54.0127.0.0.3
124.123.123.1237.0.0.4
18.12.51.327.0.0.5

<tbody>
</tbody>

Where the values in the Check IP Column can be changed fluidly but is checked against the "Master Single IP list" and against all IPs within the ranges of "Master IP Range List"

Any attempts would need to be able to scale to be able to handle thousands of IPs if possible...

I know this is asking a lot, especially for a brand new member, but this would be a great way to streamline a tedious task I do daily...

Thank You in Advance.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,215,425
Messages
6,124,826
Members
449,190
Latest member
rscraig11

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