Results 1 to 4 of 4

Thread: Help: Searching and extracting data from rows

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0

    Help: Searching and extracting data from rows

    Hi All,


    I need help with a large file consisting of thousands of rows and one column, the data does not have a defined format so each entry is different. However, there is a common occurrence in those rows and I'd like to extract them. For example:
    Cell A1:
    lariahfi area gfdgfd aevfgre rgde 127.1.1.0 afewa 1fdsa 00:00:00:13:11:3d afd aea

    Cell A2:
    agrda gfr aaa 127.0.1.42 afda 11:11:11:1f:ff:ff dawfw ged

    Cell A3:
    agdad 1.1.1.1 afewa gvr 31:42:13:12:12:12 af

    I'd like to be able to pull the following output:
    Column B:
    127.1.1.0
    127.0.1.42
    1.1.1.1


    Column C:
    00:00:00:13:11:3d
    11:11:11:1f:ff:ff
    31:42:13:12:12:12

    Any help is greatly appreciated.

    Thanks!

  2. #2
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    14
    Have not figured how to do the IP addresses but here is the formula for column C

    =MID(A1,FIND(":",A1)-2,17)

  3. #3
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    UDF will make your job easy. Do you want macro?
    Last edited by LalitPandey87; 06-18-2014 at 09:32 AM.

  4. #4
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    Here is UDF you can use:

    Code:
    Function LMP_ExtractValue1(ByVal Text As Range)
    
    
        Dim RegExp              As Object
        Dim allMatches          As Object
        Dim Result              As String
        
        Set RegExp = CreateObject("vbscript.regexp")
        RegExp.Pattern = ".*?(\d{1,3}(\.\d{1,3}){3})|.*"
        Set allMatches = RegExp.Execute(Text)
        If LenB(Trim(Text)) > 0 Then
            If allMatches.Count <> 0 Then
                Result = allMatches.Item(0).submatches.Item(0)
            End If
        Else
            Result = CVErr(xlErrValue)
        End If
        
        LMP_ExtractValue1 = Result
    
    
    End Function
    How to use:
    Code:
    =LMP_ExtractValue1(A1)

    Code:
    Function LMP_ExtractValue2(ByVal Text As Range)
    
    
        Dim RegExp              As Object
        Dim allMatches          As Object
        Dim Result              As String
        
        Set RegExp = CreateObject("vbscript.regexp")
        RegExp.Pattern = "((\:[0-9,A-Z,a-z]|[0-9,A-Z,a-z]{1,2}){11})"
        Set allMatches = RegExp.Execute(Text)
        If LenB(Trim(Text)) > 0 Then
            If allMatches.Count <> 0 Then
                Result = allMatches.Item(0).submatches.Item(0)
            End If
        Else
            Result = CVErr(xlErrValue)
        End If
        
        LMP_ExtractValue2 = Result
    
    
    End Function
    How to use:
    Code:
    =LMP_ExtractValue2(A1)

Similar Threads

  1. Replies: 34
    Last Post: 03-13-2015, 02:26 PM
  2. VBA Code For Extracting Data From Webpage In HTML5
    By prabhu venkatraman in forum Excel Help
    Replies: 1
    Last Post: 07-07-2013, 02:06 AM
  3. Replies: 6
    Last Post: 06-01-2013, 03:24 PM
  4. Extracting Unique Data
    By Howardc in forum Excel Help
    Replies: 4
    Last Post: 07-17-2012, 09:42 PM
  5. Transpose data into Rows
    By vikash200418 in forum Excel Help
    Replies: 2
    Last Post: 04-10-2012, 11:02 PM

Posting Permissions

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