+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    02-25-2010
    Location
    Sthlm
    MS-Off Ver
    Excel 2007
    Posts
    3

    Creating and filling out columns automatically

    Hey all!

    I am sitting with a quiet large "logfile" I want to present...
    But first I need to break it up into columns, and so far I have manually ctrl+x, ctrl+v everything, but I am about to go nuts from doing it... =)

    Currently I have all my data in one column, and it looks like this (the number of rows under each "Logfile xxx" differs greatly...some have one row, others have 30+ rows):


    Logfile xxx
    1324657
    1234567
    1324657
    Logfile xxx
    1234567
    1234567
    1234567

    and so on....


    I want Excel to "cut out" each part starting at "Logfile xxx" all the way down to right before the next "Logfile xxx" and paste that into a new column.

    So it will look like this basically:

    Logfile xxx | Logfile xxx
    1324657 | 1324657
    1234567 | 1324657
    1324657 | 1324657

    and so on....

    I have about 11k rows to do, so you might imagine my frustration =)

    Any suggestions on how to do this?

    Thanx alot!
    Last edited by wharfedale; 02-25-2010 at 11:24 AM.

  2. #2
    Forum Guru
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2003, 2007.
    Posts
    1,413

    Re: Creating and filling out columns automatically

    wharfedale,

    Welcome to the Excel Forum.

    Please attach your workbook, or, attach a sample of your workbook/worksheet.

    Click on "New Post", then scroll down and see "Manage Attachments".
    Have a great day,
    Stan
    stanleydgromjr
    Windows Vista Business, Excel 2003 and 2007

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Forum Guru mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    2,815

    Re: Creating and filling out columns automatically

    Try this macro.

    Code:
    Sub MySplit()
    CurrentColumn = 2
    For N = 1 To Cells(Rows.Count, 1).End(xlUp).Row
        If Left(Cells(N, 1), 7) = "Logfile" Then
            CurrentColumn = CurrentColumn + 1
            Cells(1, CurrentColumn) = Cells(N, 1)
        Else
            Cells(Rows.Count, CurrentColumn).End(xlUp).Offset(1, 0) = Cells(N, 1)
        End If
    Next N
    End Sub
    I'm assuming that your data is in column A and other columns are empty.

    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007.
    Martin

    Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.

    If my solution has saved you time and/or money, please consider donating to Cancer Research UK.

  4. #4
    Registered User
    Join Date
    02-25-2010
    Location
    Sthlm
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Creating and filling out columns automatically

    Hey all again!

    Thanx alot for that code-snippet mrice!
    Unfortunately it did not work for me... It transformed my data into two columns....
    Maybe I did something wrong?

    I attached a smaller version of my project (keep in mind that the original has well over 11000 rows) for you to take a glimpse at...
    Worksheet 1 is what it looks like now, and on worksheet 2 it is what I want the data to look like =)

    Any help would be much appreciated!
    Attached Files Attached Files

  5. #5
    Forum Guru mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2007/2010
    Posts
    2,815

    Re: Creating and filling out columns automatically

    Slight change needed.

    Code:
    Sub MySplit()
    CurrentColumn = 2
    For N = 1 To Cells(Rows.Count, 1).End(xlUp).Row
        If InStr(Cells(N, 1), "Logfile") > 0 Then    
            CurrentColumn = CurrentColumn + 1
            Cells(1, CurrentColumn) = Cells(N, 1)
        Else
            Cells(Rows.Count, CurrentColumn).End(xlUp).Offset(1, 0) = Cells(N, 1)
        End If
    Next N
    End Sub
    Martin

    Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.

    If my solution has saved you time and/or money, please consider donating to Cancer Research UK.

  6. #6
    Forum Guru
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2003, 2007.
    Posts
    1,413

    Re: Creating and filling out columns automatically

    wharfedale,

    With your raw data in Sheet1, Sheet2 will contain your results.

    Detach/open the attached workbook "RearrangeData - Creating and filling out columns automatically - wharfedale - SDG11.xlsm" and run macro "RearrangeData".
    Have a great day,
    Stan
    stanleydgromjr
    Windows Vista Business, Excel 2003 and 2007

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  7. #7
    Registered User
    Join Date
    02-25-2010
    Location
    Sthlm
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Creating and filling out columns automatically

    Wow!
    Thanx alot guys!
    I really appreciate all the help!
    Both solutions from stanleydgromjr and mrice worked like a charm!
    Awsome!

    Thank you again!

    Best regards,
    wharfedale

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0