+ Reply to Thread
Results 1 to 5 of 5

VBA to distribute data in column into columns and rows

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    DC
    MS-Off Ver
    Excel 2007
    Posts
    24

    VBA to distribute data in column into columns and rows

    I have a spreadsheet attached that contains data in column A (sheet "Column"). I would like to know if I can use VBA fill the data into a table that is five columns wide to make it look like (sheet "Distributed'). The quantity of items in column A will vary so the number of rows on the "Distributed" sheet will also vary. Eventually this table will be copied into a Word document.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA to distribute data in column into columns and rows

    Here's a macro for parsing a column of data into other multiple columns. There are two versions. Part 1 - parses non-contiguous data into columns, keeping each "set" together.
    Part 2 - parses contiguous data into columns using the number of cells per group you indicate.
    There's a sample workbook too you could drop your data into and test it out.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-12-2012
    Location
    DC
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: VBA to distribute data in column into columns and rows

    Thanks, but here is my problem. I need the data spread out into exactly five columns. I don't care how many rows, but the # of columns must be five, and the number of items in column A will vary. I guess I could find that out by counting the number of rows? #2 would work if I knew how many cells to select for each column and if I could limit it to five columns.

  4. #4
    Registered User
    Join Date
    09-12-2012
    Location
    DC
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: VBA to distribute data in column into columns and rows

    After looking at the potential data I will see in this report and also the size limitations of the pages it will be inserted into in Word, I have a question. Could Part 2 above be modified to set the number of cells per group to 35 and limit the number of columns created to six? (I know I said five, but I tested and I have room for six). Then if there was additional data in the column that would not fit into that size range, it would skip a row and create a second range and so on for the remaining data. That would make it easy to select blocks of numbers that could be inserted into the word document.

  5. #5
    Registered User
    Join Date
    09-12-2012
    Location
    DC
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: VBA to distribute data in column into columns and rows

    Did some more searching and found a solution here:

    http://www.pcreview.co.uk/forums/urg...-t1035328.html

    Modified the code slightly to the following and it works:

    Please Login or Register  to view this content.

+ 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