How to duplicate rows x number of times
Closed
carlos.guerrero18
Posts
3
Registration date
Tuesday July 9, 2019
Status
Member
Last seen
July 9, 2019
-
Jul 9, 2019 at 03:24 PM
Blocked Profile - Jul 9, 2019 at 04:50 PM
Blocked Profile - Jul 9, 2019 at 04:50 PM
Related:
- How to duplicate rows in excel x times
- Number to words in excel - Guide
- You have guessed too many times ✓ - WhatsApp Forum
- How to take screenshot in excel - Guide
- You've tried to log in too many times. to protect your account, a temporary block has been placed on logging in. please try again later. ✓ - Facebook Forum
- How to change author in excel - Guide
Jul 9, 2019 at 03:30 PM
Jul 9, 2019 at 03:40 PM
Sub CopyData()
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, "Z")).Copy
Range(Cells(xRow + 1, "A"), Cells(xRow + VInSertNum - 1, "Z")).Select
Selection.Insert Shift:=xlDown
xRow = xRow + VInSertNum - 1
End If
xRow = xRow + 1
Loop
Application.ScreenUpdating = False
End Sub
But I'm getting a bug in the "If ((VInSertNum > 1) And IsNumeric(VInSertNum)) Then" line. Any idea?
Updated on Jul 10, 2019 at 01:05 PM
msgbox("the variable is " & VInSertNum)
BTW, is there a numeric value in cell(xRow,"B")?
You may have to put Thisworkbook.worksheets("yoursheetname").Cells(xRow,"B") in the variable initialization of:
VInSertNum = Thisworkbook.WorkSheets.("yoursheetname").Cells(xRow, "B").value
Give it try!