Advertisement
lilacc

Untitled

Mar 29th, 2021
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Option Explicit
  2. Sub Macro1()
  3.  
  4. 'Written by Trebor76
  5. 'Visit my website www.excelguru.net.au
  6.  
  7. Dim lngMyRow As Long
  8. Dim lngLastRow As Long
  9. Dim rngMyRange As Range
  10.  
  11. lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
  12.  
  13. For lngMyRow = 201 To lngLastRow Step 201
  14.  
  15. If lngMyRow <> 201 Then lngMyRow = lngMyRow - 1
  16.  
  17. If rngMyRange Is Nothing Then
  18. Set rngMyRange = Cells(lngMyRow, "A")
  19. Else
  20. Set rngMyRange = Union(rngMyRange, Cells(lngMyRow, "A"))
  21. End If
  22.  
  23. Next lngMyRow
  24.  
  25. rngMyRange.EntireRow.Insert
  26.  
  27. Application.ScreenUpdating = True
  28.  
  29. MsgBox "Rows have now been inserted"
  30.  
  31. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement