richard cheung
New Member
- Joined
- Aug 23, 2021
- Messages
- 3
- Office Version
- 365
Here is the code for the Excel VBA
---
Sub CopyData()
'Updateby Extendoffice
Dim xRow As Long
Dim VInSertNum As Variant
xRow = 1
Application.ScreenUpdating = False
Do While (Cells(xRow, "A") <> "")
VInSertNum = Cells(xRow, "B")
If ((VInSertNum > 1) And IsNumeric(VInSertNum)) Then
Range(Cells(xRow, "A"), Cells(xRow, "B")).Copy
Range(Cells(xRow + 1, "A"), Cells(xRow + VInSertNum - 1, "B")).Select
Selection.Insert Shift:=xlDown
xRow = xRow + VInSertNum - 1
End If
xRow = xRow + 1
Loop
Application.ScreenUpdating = False
End Sub