Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub CopyData()
- 'Declare all variables
- Dim bInsertParent As Variant
- Dim iLastRow As Integer
- Dim iTotalRows As Integer
- 'Get index for the last row
- iTotalRows = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
- 'Start inserting stuff after the last populated row
- iLastRow = iTotalRows + 1
- Application.ScreenUpdating = False
- 'Start at the second row
- For iRowIndex = 2 To iTotalRows
- 'Fetch insert parent flag
- bInsertParent = Cells(iRowIndex, "X")
- 'If column X for iRowIndex equals 2 and is numeric
- If ((bInsertParent = 2) And IsNumeric(bInsertParent)) Then
- 'Copy and paste special macro calls
- Rows(iRowIndex).Copy
- Rows(iLastRow).PasteSpecial xlPasteAll
- 'Last row is now the next available row
- iLastRow = iLastRow + 1
- End If
- Next iRowIndex
- Application.ScreenUpdating = True
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement