I have a list with over 50000 rows. Today, I use this macro manually to insert new lines based on an active cell value:
I have created a dummy variable in column A to tell me where I need to run the macro. So I thought there must be a way to automatically insert new lines. Every time there is a cell with value "1" in column A I want to run the macro, but I'm facing troubles since the macro is written with ActiceCell.Value, and I need it to be done automatically.
0
0
0
0
1: run macro
0
0
0
0
0
0
0
1: run macro
Do you know how to help me?
Code:
Sub Insert_Rows()
r = ActiveCell.Row
p = ActiveCell.Value
NumLines = 13 - p
If NumLines = 0 Then
GoTo EndInsertLines
End If
Do
r = ActiveCell.Row
ActiveCell.Offset(1).EntireRow.Insert Shift:=xlDown
Range("D" & r + 1 & ":AC" & r + 1).Formula = Range("D" & r & ":AC" & r).Formula
Count = Count + 1
Loop While Count < NumLines
EndInsertLines:
End Sub
I have created a dummy variable in column A to tell me where I need to run the macro. So I thought there must be a way to automatically insert new lines. Every time there is a cell with value "1" in column A I want to run the macro, but I'm facing troubles since the macro is written with ActiceCell.Value, and I need it to be done automatically.
0
0
0
0
1: run macro
0
0
0
0
0
0
0
1: run macro
Do you know how to help me?