+ Reply to Thread
Results 1 to 1 of 1

Splitting a list of data into multiple columns

Hybrid View

  1. #1
    Registered User
    Join Date
    01-31-2013
    Location
    istanbul
    MS-Off Ver
    Excel 2011
    Posts
    1

    Splitting a list of data into multiple columns

    Quote Originally Posted by stanleydgromjr View Post
    From post: http://www.excelforum.com/excel-gene...-new-post.html

    PeterGriffin,

    Welcome to the Excel Forum.

    With your data in column A, beginning in row 1.



    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    Adding the Macro
    1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    
    Option Explicit
    Sub SplitData()
    Dim LR As Long, MaxCells As Integer, NC As Long, a As Long
    NC = 2
    With ActiveSheet
      LR = .Cells(Rows.Count, 1).End(xlUp).Row
      On Error GoTo ErrorRoutine
      MaxCells = InputBox("Enter the maxium integer number of cells per column?")
      If MaxCells >= LR Or MaxCells <= 0 Then
        Exit Sub
      Else
        Application.ScreenUpdating = False
        For a = MaxCells To LR Step MaxCells
          .Range("A" & a + 1 & ":A" & a + MaxCells).Copy .Cells(1, NC)
          NC = NC + 1
        Next a
        .Range("A" & MaxCells + 1 & ":A" & LR).ClearContents
      End If
    End With
    Application.ScreenUpdating = True
    Exit Sub
    ErrorRoutine:
    Application.ScreenUpdating = True
    MsgBox "You did not enter an integer value - macro terminated!"
    End Sub

    Then run the "SplitData" macro.
    wow this is amazing! it is 2 years old but exactly what i needed!
    I hope still hear me

    I need right this thing but I have data of 3 columns! What kind of change do I need to make in the code?
    Thanks!
    Last edited by JBeaucaire; 01-31-2013 at 07:14 PM. Reason: Moved to a thread of its own, as per forum rules. PLEASE read the forum rules, link is above in the menu bar.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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