Sub CC()
Dim lngLastRow As Long, lngRow As Long
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
lngLastRow = Range("A" & Rows.Count).End(xlUp).Row
For lngRow = lngLastRow To 2 Step -1
If Right(Range("B" & lngRow), 5) = "Total" Then Rows(lngRow).Delete
Next lngRow
For lngRow = lngLastRow To 2 Step -1
If Right(Range("A" & lngRow), 5) = "Total" Then Rows(lngRow).Delete
Next lngRow
For lngRow = lngLastRow To 2 Step -1
If Right(Range("B" & lngRow), 5) = "total" Then Rows(lngRow).Delete
Next lngRow
For lngRow = lngLastRow To 2 Step -1
If Right(Range("A" & lngRow), 5) = "total" Then Rows(lngRow).Delete
Next lngRow
For lngRow = lngLastRow To 2 Step -1
If Left(Range("B" & lngRow), 5) = "Total" Then Rows(lngRow).Delete
Next lngRow
For lngRow = lngLastRow To 2 Step -1
If Left(Range("A" & lngRow), 5) = "Total" Then Rows(lngRow).Delete
Next lngRow
For lngRow = lngLastRow To 2 Step -1
If Left(Range("B" & lngRow), 5) = "total" Then Rows(lngRow).Delete
Next lngRow
For lngRow = lngLastRow To 2 Step -1
If Left(Range("A" & lngRow), 5) = "total" Then Rows(lngRow).Delete
Next lngRow
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
Lastrow = Range("E" & Rows.Count).End(xlUp).Row
Range("A7 : C" & Lastrow).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, SkipBlanks:=False, Transpose:=False
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
With Range("A7:C" & Lastrow)
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
With Range("A7:C" & Lastrow)
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
End Sub
If the user clicks on the button more than once, a msg box woould appear stating "Runtime Error '1004': Method Range of Object '_Global' Failed"/ However, nothing would happen to the fields or data. Is there a way to add a line of code such that when user decides or accidentally presses the button more than once, no error msg would appear and noting will happen to the data?
Bookmarks