Pulling IP Addresses out of log files.

marksman681

New Member
Joined
May 11, 2022
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
Hello I am having an issue and need some help. I have some SSH log files in excel. Column C is where the data is. There is a lot of text wrapped around the IP address and I want to be able to pull it out into a different column. The text that is around the IP address is random in length. I do not need anything that is missing an octet but if it grabs it I do not care.
 

Attachments

  • Annotation 2022-05-11 162423.jpg
    Annotation 2022-05-11 162423.jpg
    184.7 KB · Views: 40

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
One way.

Book1 (version 2).xlsb
AB
1ABC 1.1.1.1 QRS1.1.1.1
2DEF 255.255.255.255 TUV255.255.255.255
3GIH 1.28.255.68 XYZ1.28.255.68
Sheet3
Cell Formulas
RangeFormula
B1:B3B1=OCTET(A1)


VBA Code:
Function OCTET(s As String)
With CreateObject("VBScript.RegExp")
    .Pattern = "(?:\d+.?)+"
    OCTET = .Execute(s)(0)
End With
End Function
 
Upvote 0
Solution
One way.

Book1 (version 2).xlsb
AB
1ABC 1.1.1.1 QRS1.1.1.1
2DEF 255.255.255.255 TUV255.255.255.255
3GIH 1.28.255.68 XYZ1.28.255.68
Sheet3
Cell Formulas
RangeFormula
B1:B3B1=OCTET(A1)


VBA Code:
Function OCTET(s As String)
With CreateObject("VBScript.RegExp")
    .Pattern = "(?:\d+.?)+"
    OCTET = .Execute(s)(0)
End With
End Function
when I do the formula all I get back is #NAME?
 
Upvote 0
@lrobbo314's code in post #2 works fine for me.

Perhaps you need to to change the 'A1' in the example to 'C1'? =OCTET(C1)
 
Upvote 0
Where did you put the code?
Is it in a normal module in that workbook?
 
Upvote 0
Where did you put the code?
Is it in a normal module in that workbook?
to be honest I have no idea where to put the code. I used the formula and it is not work. I tried it on a windows machine and a mac. neither worked. I know they older versions and when typing in the formula that one does not pop up.
 
Upvote 0
In the VB editor click "Insert" then "Module" & paste the code in there. You will need to save the workbook as macro enabled.
 
Upvote 0
In the VB editor click "Insert" then "Module" & paste the code in there. You will need to save the workbook as macro enabled.
ok i must be really messing something up. I did what you said and it is all there but now I need to know how to run the macro.
In the VB editor click "Insert" then "Module" & paste the code in there. You will need to save the workbook as macro enabled.
ok still not working and I am not sure what I am doing wrong
 

Attachments

  • Screen Shot 2022-05-12 at 10.51.25 AM.png
    Screen Shot 2022-05-12 at 10.51.25 AM.png
    136.5 KB · Views: 25
  • Screen Shot 2022-05-12 at 10.51.59 AM.png
    Screen Shot 2022-05-12 at 10.51.59 AM.png
    98.3 KB · Views: 13
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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