Advertisement
Guest User

Untitled

a guest
Aug 6th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub CopyData()
  2.     Dim xRow As Long
  3.     Dim VInSertNum As Variant
  4.     Dim lastrow As Long
  5.     xRow = 2
  6.     lastrowplus = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
  7.     lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
  8.     Application.ScreenUpdating = False
  9.     Do While (Cells(xRow, "A") <> "")
  10.         VInSertNum = Cells(xRow, "X")
  11.         If ((VInSertNum > 0) And IsNumeric(VInSertNum)) Then
  12.             Range(Cells(xRow, "A"), Cells(xRow, "BB")).Copy
  13.             Range(Cells(lastrow, "A"), Cells(lastrow, "BB")).Select
  14.             Selection.Insert Shift:=xlDown
  15.             xRow = xRow + VInSertNum - 1
  16.             Range(Cells(lastrow, "C"), Cells(lastrow, "C")).Value = Application.VLookup(Cells(lastrow, "A"), Sheet16.Range("A1:C26"), 3, False)
  17.             Range(Cells(lastrow, "A"), Cells(lastrow, "A")).Value = Application.VLookup(Cells(lastrow, "A"), Sheet16.Range("A1:C26"), 2, False)
  18.             Range(Cells(lastrow, "O"), Cells(lastrow, "O")).Value = 0
  19.             Range(Cells(lastrow, "Q"), Cells(lastrow, "Q")).Value = 0
  20.             Range(Cells(lastrow, "X"), Cells(lastrow, "X")).Value = 0
  21.             Range(Cells(lastrow, "Z"), Cells(lastrow, "Z")).Copy
  22.             Range(Cells(lastrow, "Z"), Cells(lastrow, "Z")).PasteSpecial xlPasteValues
  23.         End If
  24.         xRow = xRow + 1
  25.     Loop
  26.     Application.ScreenUpdating = False
  27. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement