M
macroapa
Hi,
I ahve the following code that loops thru each row and if the criteria
is met it deletes the row. However it runs really slowly. Is there a
way to acheive the same thing more effeiciently? Thanks
Sub removeNTUs()
Dim xR As Long
Dim xCw As Integer
Dim xCA As Integer
Dim wStep As String
Dim AStatus As String
Dim xStop As Long
xCw = 19
xCA = 20
xStop = Workbooks("pipeline reporting.xls").Worksheets
("variables").Cells(2, 2).Value + 12
xR = 15
Do
Debug.Print (xR)
wStep = Workbooks("pipeline reporting.xls").Worksheets
("Pipeline").Cells(xR, xCw).Value
AStatus = Workbooks("pipeline reporting.xls").Worksheets
("Pipeline").Cells(xR, xCA).Value
If wStep = "Diary - NTU" And AStatus = "Not Taken Up" Then
Rows(xR & ":" & xR).Delete Shift:=xlUp
xR = xR - 1
xStop = xStop - 1
End If
xR = xR + 1
Loop Until xR = xStop
MsgBox ("ended")
End Sub
I ahve the following code that loops thru each row and if the criteria
is met it deletes the row. However it runs really slowly. Is there a
way to acheive the same thing more effeiciently? Thanks
Sub removeNTUs()
Dim xR As Long
Dim xCw As Integer
Dim xCA As Integer
Dim wStep As String
Dim AStatus As String
Dim xStop As Long
xCw = 19
xCA = 20
xStop = Workbooks("pipeline reporting.xls").Worksheets
("variables").Cells(2, 2).Value + 12
xR = 15
Do
Debug.Print (xR)
wStep = Workbooks("pipeline reporting.xls").Worksheets
("Pipeline").Cells(xR, xCw).Value
AStatus = Workbooks("pipeline reporting.xls").Worksheets
("Pipeline").Cells(xR, xCA).Value
If wStep = "Diary - NTU" And AStatus = "Not Taken Up" Then
Rows(xR & ":" & xR).Delete Shift:=xlUp
xR = xR - 1
xStop = xStop - 1
End If
xR = xR + 1
Loop Until xR = xStop
MsgBox ("ended")
End Sub