LostandAngryatVBA
New Member
- Joined
- Jul 9, 2024
- Messages
- 6
- Office Version
- 365
- Prefer Not To Say
- Platform
- Windows
Hello all,
I have been stuck 5 hours on this topic. Please help.
I have a code as below. First part is to add one empty line. Next part is an “i” loop where It is adding empty lines based on value of certain cell. This code lags my macro so bad, like 2-3min when I run it. It even crash. The ironic thing is I have 2 subs branch out and when branch 1 run this code it works fine vs when it enters another branch, it lag/crash. Therefore I know the codes work but I’m confused why one sub works fast and one die. Regardless, I’m looking to improve my codes so it doesn’t lag/crash
Application.CutCopyMode = False
Application.ScreenUpdating = False
Sheets("worksheet1").Select
Range("F2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Supply = Range("AO189")
Dim i As Integer
Dim numdx As Integer
numdx = Range("t219") + 4
Range("F1").Select
ActiveCell.Offset(Tier + 7).Select ' space in inc note
For i = 1 To numdx
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next i
I have been stuck 5 hours on this topic. Please help.
I have a code as below. First part is to add one empty line. Next part is an “i” loop where It is adding empty lines based on value of certain cell. This code lags my macro so bad, like 2-3min when I run it. It even crash. The ironic thing is I have 2 subs branch out and when branch 1 run this code it works fine vs when it enters another branch, it lag/crash. Therefore I know the codes work but I’m confused why one sub works fast and one die. Regardless, I’m looking to improve my codes so it doesn’t lag/crash
Application.CutCopyMode = False
Application.ScreenUpdating = False
Sheets("worksheet1").Select
Range("F2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Supply = Range("AO189")
Dim i As Integer
Dim numdx As Integer
numdx = Range("t219") + 4
Range("F1").Select
ActiveCell.Offset(Tier + 7).Select ' space in inc note
For i = 1 To numdx
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next i