+ Reply to Thread
Results 1 to 6 of 6

make all data sets in different rows

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Post make all data sets in different rows

    dear friends in my document column "B" has different sets of data.first row has document header.that each sets should start with row 7,12,17,22,etc...
    for that i have tried below macro & it's work very well.only the problem is this macro rows counting start from first row.but i want to change it to second row.(first row has header) pls help me how i can i do it......

    Sub newinsertrows()
    Dim groupsize As Integer
    groupsize = 5
    Range("B3").Select
    Do While IsEmpty(ActiveCell) = False
        If ActiveCell.Value <> ActiveCell.Offset(-1, 0).Value Then
            Do While ActiveCell.Row Mod groupsize <> 1
                ActiveCell.EntireRow.Insert shift:=xlDown
                ActiveCell.Offset(1, 0).Select
            Loop
        End If
        
        ActiveCell.Offset(1, 0).Select
    Loop
    End Sub

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: make all data sets in different rows

    Don't use select or activate in VBA.
    sub alt1()
      for j=sheets(1).usedrange.rows.count to 2 step -5
         sheets(1).rows(j).resize(5).insert
      next
    End Sub

  3. #3
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Re: make all data sets in different rows

    Quote Originally Posted by snb View Post
    Don't use select or activate in VBA.
    sub alt1()
      for j=sheets(1).usedrange.rows.count to 2 step -5
         sheets(1).rows(j).resize(5).insert
      next
    End Sub
    thanks for your reply but this not work for me.macro should run base on column "B".pls help me..

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: make all data sets in different rows

    Did you try to read the code I gave ?
    Did you analyse it ?
    Do you know what usedrange means ?

  5. #5
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Re: make all data sets in different rows

    Quote Originally Posted by snb View Post
    Did you try to read the code I gave ?
    Did you analyse it ?
    Do you know what usedrange means ?
    i have attached sample sheet.pls check it.my problem is as a my sample sheet second set should start with row # 7.but my macro it's starting with row # 6.pls help me,..
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Re: make all data sets in different rows

    any other helps..

+ 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