• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Split single row in multiple rows (sequential number 1/5..5/5)

marreco

Member
Hi
Code:
Sub CriarVolume()
LastRow = Cells(Rows.Count, 9).End(xlUp).Row

For i = LastRow To 2 Step -1
    If Cells(i, 9).Value > 1 Then
        Num = Cells(i, 9).Value
        For j = 1 To Num
            Rows(i + 1).EntireRow.Insert
            Rows(i).Copy Rows(i + 1)
        Next
        Rows(i).EntireRow.Delete
    End If
Next
End Sub
my loop check value in column I and replicate rows, but i need create a sequential number.
Look my image to understand.

Thank you!
 

Attachments

  • Volumes.jpg
    Volumes.jpg
    346.8 KB · Views: 6
try:
Code:
Sub CriarVolume2()
LastRow = Cells(Rows.Count, 9).End(xlUp).Row

For i = LastRow To 2 Step -1
  If Cells(i, 9).Value > 1 Then
    num = Cells(i, 9).Value
    Rows(i).Copy
    Rows(i + 1).Resize(num - 1).Insert
    k = 1
    For j = i To i + num - 1
      With Cells(j, "I")
        .NumberFormat = "@"
        .Value = k & "/" & num
      End With
      k = k + 1
    Next j
  End If
Next i
End Sub
but be aware that the values in column I which have a forward slash in them are no longer numbers, but text.
 
Back
Top