JeffGrant
Well-known Member
- Joined
- Apr 7, 2021
- Messages
- 516
- Office Version
- 365
- Platform
- Windows
Hi,
I have this macro
Which works like a treat in one workbook with one sheet. The macro is placed in a module. However, when the macro is transferred to another workbook, the Selection.EntireRow.Insert line goes to into an endless loop and requires a manual break to abort it.
In the first workbook, the process takes less than 2 seconds to complete on 3000 + records.
In the second workbook, where there are many sheets and any many module, the Selection.EntireRow.Insert goes into an endless loop - i think.......
The data is located in the same columns and rows. The sheets are named exactly the same.
Any guidance would be most appreciated.
Thanks in advance.
I have this macro
VBA Code:
Sub Macro1()
LR = Cells(Rows.Count, 2).End(xlUp).Row
With Range("J4:J" & LR)
.FormulaR1C1 = _
"=IF(RC[-5]*2-MINUTE(RC[-5]*120)/24/60/60<R[-1]C[-5]*2-MINUTE(R[-1]C[-5]*120)/24/60/60,1,"""")"
.Value = .Value
.SpecialCells(xlCellTypeConstants, 1).Select
.Clear
End With
Selection.EntireRow.Insert
End Sub
Which works like a treat in one workbook with one sheet. The macro is placed in a module. However, when the macro is transferred to another workbook, the Selection.EntireRow.Insert line goes to into an endless loop and requires a manual break to abort it.
In the first workbook, the process takes less than 2 seconds to complete on 3000 + records.
In the second workbook, where there are many sheets and any many module, the Selection.EntireRow.Insert goes into an endless loop - i think.......
The data is located in the same columns and rows. The sheets are named exactly the same.
Any guidance would be most appreciated.
Thanks in advance.