Large Data Pool Import & Transpose

Hey all, simple question I'd assume..

I have a notepad file, currently saved as a .log file. I need to import it into Excel. Easy enough, with the import external data feature. My issue arises due to the fact I need to transpose this data, which is easy to do, but I have 255 entries I need transpose. Is there an option / way to specify the transpose when importing the data in excel?

Currently, the data looks like this;

Host Name:         No DNS Entry
IP Address:        192.168.1.1
Ping Response:     ip dest host unreachable
Ethernet Address:  
Network Interface:
Host Type:        
Open Ports:        
FTP Server:        
WINS Name:        
Windows Workgroup:
Current User:      
WINS Comment:

I need the entire field of 255 IP's transposed across. I can create the horizontal Host Name, IP Address, etc title blocks, but how do I go about transposing the actual data I've gotten off my network scan, without doing it 255 times?

Thanks
microsymplexAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick MatthewsCommented:
It would be helpful if you could upload a sample of your log file, and a mockup of how the results should look in Excel.

Be sure to first obfuscate any sensitive data in the log :)
0
microsymplexAuthor Commented:
Attached are my examples. the notepad example is how I get the raw data from my scanning software, netpeek. the green excel cells are how they are getting imported now, the cells in orange are how I want them to be imported, horizontally instead of vertically. Remember I have my entire subnet to do, all 255 addresses, so a simple copy and transpose is not necessarily feasible.

Thanks!
example.txt
example2.xlsx
0
Patrick MatthewsCommented:
Please download the file below, and run the macro GetTheData.

It reads the data from the text file, and writes the results to a new workbook.
Sub GetTheData()
    
    Dim fso As Object
    Dim ts As Object
    Dim ws As Worksheet
    Dim FilePath As Variant
    Dim UseRow As Long
    Dim TheLine As String
    Dim Header As String
    Dim Item As String
    Dim UseCol As Long
    
    FilePath = Application.GetOpenFilename("Text (*.txt), *.txt", , "Select log file", , False)
    If FilePath = False Then
        MsgBox "No file selected", vbCritical, "Aborting..."
        Exit Sub
    End If
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.OpenTextFile(FilePath)
    ThisWorkbook.Worksheets(1).Copy
    Set ws = ActiveSheet
    
    UseRow = 1
    
    Do Until ts.AtEndOfStream
        TheLine = ts.ReadLine
        If InStr(1, TheLine, ":") > 0 Then
            Header = Split(TheLine, ":")(0)
            Item = Trim(Split(TheLine, ":")(1))
            If StrComp(Header, "Host Name", vbTextCompare) = 0 Then UseRow = UseRow + 1
            UseCol = Application.Match(Header, ws.[1:1], 0)
            ws.Cells(UseRow, UseCol) = Item
        End If
    Loop
    
    ts.Close
    Set ts = Nothing
    Set fso = Nothing
    
    ws.Columns.AutoFit
    
    MsgBox "Done"
    
End Sub

Open in new window

Q-25755763.xls
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

microsymplexAuthor Commented:
Thanks, but when I go to open the text file with all the data (not the example I uploaded) Excel does not list it as an option in the folder where I have it stored.
0
Patrick MatthewsCommented:
Change:

    FilePath = Application.GetOpenFilename("Text (*.txt), *.txt", , "Select log file", , False)

to:

    FilePath = Application.GetOpenFilename("Log (*.log), *.log", , "Select log file", , False)
0
microsymplexAuthor Commented:
Disregard the other error, but when I open it, I get a run time error '13': Type Mismatch.
0
Patrick MatthewsCommented:
When I run the macro against the sample file you provided, it works perfectly.

Which line did the debugger jump to, and can you post the exact file you tried to run against?
0
microsymplexAuthor Commented:
I can't post the exact file, since it has mac addresses, ports, names, ip's, etc. But the format is exactly the same as the example I posted, only it's all 255 IP address, not the 5 or 6 that were included in my example. I apologize for not making that more clear...Yes the macro works with the example, but not the full file I need to run it on in my production environment.

Thanks!
0
Patrick MatthewsCommented:
Try this...



Sub GetTheData()
    
    Dim fso As Object
    Dim ts As Object
    Dim ws As Worksheet
    Dim FilePath As Variant
    Dim UseRow As Long
    Dim TheLine As String
    Dim Header As String
    Dim Item As String
    Dim UseCol As Long
    
    FilePath = Application.GetOpenFilename("Log (*.log), *.log", , "Select log file", , False)
    If FilePath = False Then
        MsgBox "No file selected", vbCritical, "Aborting..."
        Exit Sub
    End If
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.OpenTextFile(FilePath)
    Set ws = Workbooks.Add.Worksheets(1)
    
    UseRow = 1
    
    Do Until ts.AtEndOfStream
        TheLine = ts.ReadLine
        If InStr(1, TheLine, ":") > 0 Then
            Header = Split(TheLine, ":")(0)
            Item = Trim(Split(TheLine, ":")(1))
            If StrComp(Header, "Host Name", vbTextCompare) = 0 Then
                UseRow = UseRow + 1
            End If
            If Application.CountIf(ws.[1:1], Header) = 0 Then
                ws.Cells(1, Application.CountA(ws.[1:1]) + 1) = Header
            End If
            UseCol = Application.Match(Header, ws.[1:1], 0)
            ws.Cells(UseRow, UseCol) = Item
        End If
    Loop
    
    ts.Close
    Set ts = Nothing
    Set fso = Nothing
    
    ws.Columns.AutoFit
    
    MsgBox "Done"
    
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
microsymplexAuthor Commented:
will test in the morning, thanks!
0
microsymplexAuthor Commented:
Ok I'm really sorry but I know nothing except total basics of macros, what do I do with the text you attached?
0
Patrick MatthewsCommented:
Hit Alt+F11 to get the VB Editor, and replace the original code I gave you with the updated code in http:#a30146310
0
microsymplexAuthor Commented:
gotcha.
0
microsymplexAuthor Commented:
Perfect, exactly what I needed. Thank you for the continued follow up and assistance!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.