I'm trying to insert a set number of rows every row. I.e. spread my condensed data out.
The code below worked with variables as int's but since changing to long due to dataset size it has seemed to have broken. It just pushes all the rows from row 2 down a few thousand as a single group. The goal is to have 74 lines in between my existing data set
Sub Run()
Dim Rng As Range
Dim xInterval As Integer
Dim xRows As Integer
Dim xRowsCount As Long
Dim xNum1 As Long
Dim xNum2 As Long
Dim WorkRng As Range
Dim xWs As Worksheet
Dim xLast As Long
xTitleId = "Input"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
xRowsCount = WorkRng.Rows.count
xInterval = Application.InputBox("Enter row interval. ", xTitleId, 1, Type:=1)
xRows = Application.InputBox("How many rows to insert at each interval? ", xTitleId, 1, Type:=1)
xNum1 = WorkRng.Row + xInterval
Set xWs = WorkRng.Parent
For i = 1 To Int(xRowsCount / xInterval)
xWs.Range(xWs.Cells(xNum1, WorkRng.Column), xWs.Cells(xNum1 + xRows - 1, WorkRng.Column)).Select
Application.Selection.EntireRow.Insert
xNum1 = xNum1 + xNum2
Next
End Sub
xnum1will never change becausexnum2has no value