+ Reply to Thread
Results 1 to 2 of 2

Excel - Expand IP address range to individual IP ?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-20-2020
    Location
    .
    MS-Off Ver
    2019
    Posts
    5

    Excel - Expand IP address range to individual IP ?

    If I've set of data like this in Ms Excel

    10.0.0.1-10.0.0.3
    172.16.0.3
    192.168.0.2-192.168.0.2

    How do I expand those IP Address and produce an output like this?

    10.0.0.1
    10.0.0.2
    10.0.0.3
    172.16.0.3
    192.168.0.2

    iNZyC.png

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Excel - Expand IP address range to individual IP ?

    Put your data in column A starting at A1.

    Then run this Macro

    
    Sub Test()
    LR = Cells(Rows.Count, 1).End(xlUp).Row
    Data = Application.Transpose(Range("A1:A" & LR).Value)
    For Count = 1 To UBound(Data)
    
    If InStr(1, Data(Count), "-") > 0 Then
    A = Split(Data(Count), "-")
    If A(0) = A(1) Then
    Output = Output & ", " & A(0)
    Else
    myBase = Left(A(0), InStrRev(A(0), "."))
    For Count2 = Split(A(0), ".")(3) To Split(A(1), ".")(3)
    Output = Output & ", " & myBase & Count2
    Next
    End If
    
    Else
    Output = Output & ", " & Data(Count)
    End If
    Next
    
    If Len(Output) > 2 Then Output = Mid(Output, 3)
    Temp = Split(Output, ",")
    Range("B1:B" & UBound(Temp) + 1).Value = Application.Transpose(Temp)
    End Sub
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ip range to individual ip address
    By bharath18091991 in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 03-20-2020, 01:55 PM
  2. Replies: 6
    Last Post: 11-13-2018, 04:54 AM
  3. Need to expand a range of years to individual years
    By chrissandu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-26-2013, 10:46 AM
  4. [SOLVED] Query Oracle using range in Excel to return individual records for each cell in range
    By bigwillydier in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-18-2013, 06:37 PM
  5. [SOLVED] Excel 2010 - Defined range does not expand when a row is inserted by a macro
    By UncleRowan in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-01-2012, 09:25 AM
  6. HOW CAN I EXPAND A RANGE IN A FUNCTION BEYOND 30 CELLS IN EXCEL?
    By excelfriendwannabie in forum Excel General
    Replies: 2
    Last Post: 03-16-2006, 12:40 PM
  7. [SOLVED] how does one expand individual cells?
    By Brian @ Pease in forum Excel General
    Replies: 1
    Last Post: 11-22-2005, 11:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1