+ Reply to Thread
Results 1 to 5 of 5

group data into groups of 10

Hybrid View

  1. #1
    Registered User
    Join Date
    07-25-2013
    Location
    stl, mo
    MS-Off Ver
    Excel 2003
    Posts
    3

    group data into groups of 10

    hi. basic macro question.
    i have data that fills into column a. i want to take this the first 10 rows and spit out the data onto r1c2 seperated by commas for example: data1,data2,data3, to data10. then on row2column2:data11,data12,data13..........then r3c2, r4c2, rowetc-c2 until its all grouped into rows of ten seperated by commas.
    This seems like it should be easy. my brains just not working right now.
    Thanks!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: group data into groups of 10

    Hello jmccarthy0901,

    Welcome to the Forum!

    Sub GroupBy10()
    
        Dim Data As Variant
        Dim i As Long
        Dim Rng As Range
        
            Set Rng = Range("A1", Cells(Rows.Count, "A").End(xlUp))
            
            For i = 1 To Rng.Rows.Count Step 10
                Data = Rng.Cells(i, 1).Resize(10, 1).Value
                Data = Application.Transpose(Data)
                Data = Application.Index(Data, 1, 0)
                Rng.Cells(i, 2).Value = Join(Data, ",")
            Next i
            
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-25-2013
    Location
    stl, mo
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: group data into groups of 10

    Thanks, can you paste the data in back to back rows instead of every tenth row there are 10 data entries?

  4. #4
    Registered User
    Join Date
    07-25-2013
    Location
    stl, mo
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: group data into groups of 10

    and if the data set isn't divisible by ten, can there not be a bunch of extra commas in the last row?

    Thanks for the help!!!

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: group data into groups of 10

    Hello jmccarthy0901,

    Here is the amended code...
    Sub GroupBy10()
    
        Dim Data As Variant
        Dim i As Long
        Dim n As Long
        Dim Rng As Range
        
            Set Rng = Range("A1", Cells(Rows.Count, "A").End(xlUp))
            
            For i = 1 To Rng.Rows.Count Step 10
                Data = Rng.Cells(i, 1).Resize(10, 1).Value
                Data = Application.Transpose(Data)
                Data = Application.Index(Data, 1, 0)
                n = n + 1
                Rng.Cells(n, 2).Value = Join(Data, ",")
            Next i
            
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How do I group multiple data entries in sub-groups
    By wendyrose1034 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  2. [SOLVED] How do I group multiple data entries in sub-groups
    By bj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 11:05 AM
  3. How do I group multiple data entries in sub-groups
    By bj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  4. How do I group multiple data entries in sub-groups
    By wendyrose1034 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  5. [SOLVED] How do I group multiple data entries in sub-groups
    By wendyrose1034 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM

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