Sam Coombes
asked on
VBA excel copy code causing excel to crash
Could anyone explain firstly why this code is causing excel to crash ? is it simple because the computer is so old.
Sub CopyRow()
Dim sws As Worksheet, dws As Worksheet
Dim lr As Long
Application.EnableEvents = False
Application.ScreenUpdating = False
Set sws = Sheets("Blueteq")
Set dws = Sheets("Sheet2")
lr = sws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPreviou s).Row
With sws.Range("AB5:AB" & lr)
.AutoFilter field:=1, Criteria1:="True"
If .SpecialCells(xlCellTypeVi sible).Cel ls.Count > 1 Then
sws.Range("AB6:AB" & lr).SpecialCells(xlCellTyp eVisible). EntireRow. Copy dws.Range("A" & Rows.Count).End(3)(2)
sws.Range("AB6:AB" & lr).SpecialCells(xlCellTyp eVisible). EntireRow. Delete
End If
.AutoFilter
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
also it is causing a slight graphical glitch in Excel so the lines not match up in one row any more as you can see in the screen shot.
Sub CopyRow()
Dim sws As Worksheet, dws As Worksheet
Dim lr As Long
Application.EnableEvents = False
Application.ScreenUpdating
Set sws = Sheets("Blueteq")
Set dws = Sheets("Sheet2")
lr = sws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPreviou
With sws.Range("AB5:AB" & lr)
.AutoFilter field:=1, Criteria1:="True"
If .SpecialCells(xlCellTypeVi
sws.Range("AB6:AB" & lr).SpecialCells(xlCellTyp
sws.Range("AB6:AB" & lr).SpecialCells(xlCellTyp
End If
.AutoFilter
End With
Application.EnableEvents = True
Application.ScreenUpdating
End Sub
also it is causing a slight graphical glitch in Excel so the lines not match up in one row any more as you can see in the screen shot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Once again thank you very much
ASKER