Calculating unique SubNets within list of IPs

ColumK

New Member
Joined
Nov 9, 2010
Messages
2
Hello,

I am OK at Excel but I have never really attempted at writing VB code. My expertise is really PHP and a bit of Java so bear with me... anyway to the question:

I have a spreadsheet of thousands of rows of websites with their IPs. What I need to do is calculate the number of unique SubNets within that column (i.e. 154.124.60 is one subnet regardless of there being multiple 154.124.60.x).

Essentially the only way I can figure out to do it is to split each cell to remove the last part of the ip then to manually remove duplicates using the function in excel. This will give me how many unique sub nets there are.

Then I want to find out how many of each appear so I would need to do a count function to see how many times each one of these appear in the column of IPs.

The problem with this is that I will be doing this every couple of weeks and so it will take a hell of a lot of time to do this manually.

I was wondering if there is an automated way?

Has anyone tried something similar before who wouldn't mind enlightening me, or alternatively point me in the direction of a few tutorials that would help me achieve this through VB/Macros? :confused:

I know from other forums that people don't like OPs not trying to do this on their own first but I have no knowledge of VB and I do not really have the time to study it (its a work project) so I do apologise not having a crack at this first.

Any help will be greatly appreciated. :)
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
can you put up a few lines of what your data looks like and an eg of the expected result pls
 
Upvote 0
Welcome to the Board.

Try a formula like:

=SUMPRODUCT(1/COUNTIF(A1:A20,LEFT(A1:A20,11)&"*"))

Expand the range references to suit, but make sure that they both have the same number of rows and avoid using entire columns.
 
Upvote 0
Welcome to the Board.

Try a formula like:

=SUMPRODUCT(1/COUNTIF(A1:A20,LEFT(A1:A20,11)&"*"))

Expand the range references to suit, but make sure that they both have the same number of rows and avoid using entire columns.

Worked perfectly, thank you!

Yes I noticed about entire columns, it crashed it when i tried.

I found using a table i.e. Table8[IP] got around it crashing. It doesn't like looking at B:B but with a table column it can. Strange.
 
Upvote 0

Forum statistics

Threads
1,214,527
Messages
6,120,057
Members
448,940
Latest member
mdusw

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