Results 1 to 2 of 2

Thread: VBA Code Issue

  1. #1
    Join Date
    Nov 2006
    Posts
    67

    Unanswered: VBA Code Issue

    Code:
    Option Explicit
     
    Sub AddRows()
        Dim LRw As Long
        Dim rng As Range
        Dim i As Long
         
        Application.ScreenUpdating = False
        LRw = Cells(Rows.Count, 1).End(xlUp).Row - 38
        For i = LRw To 4 Step -39
            Set rng = Union(Cells(i + 9, 1), Cells(i + 23, 1), Cells(i + 24, 1), _
            Cells(i + 32, 1), Cells(i + 36, 1), Cells(i + 39, 1))
            rng.EntireRow.Insert
            Set rng = Nothing
        Next
        Application.ScreenUpdating = True
    End Sub

    I tried this code. But the new rows are inserted at the wrong places. My first row (or first customer) starts at row4, 2nd starts at row 43, 82 and so on. (everyone customer has 39 rows).

    For my first customer, I need to insert new rows at row 13, 23, 28, 36,40 and 43. For my second customers, new rows need to be inserted at 13+39, 23 +39.....43+39.

    Not sure if this helpful, but there might be a empty space at row 13, 23, or 28. Because other columns at row 13, 23 or 28 might have data in them, I am trying to insert a row so.. all columns are empty.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2006
    Posts
    67
    Oh my, I posted this at the wrong forum. Sorry!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •