T
Todd Huttenstine
THIS CODE WILL WORK:
Private Sub CommandButton2_Click()
Dim i As Integer
Dim iLastrow As Integer
Dim Collet As String
Dim rng As Range
Dim cl As Object
Dim numcount3 As Long
numcount3 = Application.WorksheetFunction.CountA(Sheets
("Resolutions").Range("AD:AD"))
For Each cell In Sheets("Resolutions").Range("AF2:AF"
& numcount3)
Set Wks = ActiveSheet
Collet = ("AE:AE")
whatwant = cell
iLastrow = Wks.Cells(Rows.Count, Collet).End
(xlUp).Row
For i = iLastrow To 1 Step -1
If Wks.Cells(i, Collet).Value Like
whatwant Then
'Wks.Rows(i).Delete 'this will delete
the entire row
Wks.Rows(i).Resize(, 2).Delete
Shift:=xlShiftUp
End If
Next i
Next cell
End Sub
THIS CODE WILL WORK:
Private Sub CommandButton3_Click()
Dim i As Integer
Dim iLastrow As Integer
Dim Collet As String
Dim rng As Range
Dim cl As Object
Dim numcount3 As Long
numcount3 = Application.WorksheetFunction.CountA(Sheets
("Resolutions").Range("A:A"))
For Each cell In Sheets("Resolutions").Range("C2:C" &
numcount3)
Set Wks = ActiveSheet
Collet = ("B:B")
whatwant = cell
iLastrow = Wks.Cells(Rows.Count, Collet).End
(xlUp).Row
For i = iLastrow To 1 Step -1
If Wks.Cells(i, Collet).Value Like
whatwant Then
'Wks.Rows(i).Delete 'this will delete
the entire row
Wks.Rows(i).Resize(, 2).Delete
Shift:=xlShiftUp
End If
Next i
Next cell
End Sub
The only difference in the 2 is that the code that will
not work is positioned furthur down the worksheet. The
data is the exact same as well.
Whats wrong here?
Todd Huttenstine
Private Sub CommandButton2_Click()
Dim i As Integer
Dim iLastrow As Integer
Dim Collet As String
Dim rng As Range
Dim cl As Object
Dim numcount3 As Long
numcount3 = Application.WorksheetFunction.CountA(Sheets
("Resolutions").Range("AD:AD"))
For Each cell In Sheets("Resolutions").Range("AF2:AF"
& numcount3)
Set Wks = ActiveSheet
Collet = ("AE:AE")
whatwant = cell
iLastrow = Wks.Cells(Rows.Count, Collet).End
(xlUp).Row
For i = iLastrow To 1 Step -1
If Wks.Cells(i, Collet).Value Like
whatwant Then
'Wks.Rows(i).Delete 'this will delete
the entire row
Wks.Rows(i).Resize(, 2).Delete
Shift:=xlShiftUp
End If
Next i
Next cell
End Sub
THIS CODE WILL WORK:
Private Sub CommandButton3_Click()
Dim i As Integer
Dim iLastrow As Integer
Dim Collet As String
Dim rng As Range
Dim cl As Object
Dim numcount3 As Long
numcount3 = Application.WorksheetFunction.CountA(Sheets
("Resolutions").Range("A:A"))
For Each cell In Sheets("Resolutions").Range("C2:C" &
numcount3)
Set Wks = ActiveSheet
Collet = ("B:B")
whatwant = cell
iLastrow = Wks.Cells(Rows.Count, Collet).End
(xlUp).Row
For i = iLastrow To 1 Step -1
If Wks.Cells(i, Collet).Value Like
whatwant Then
'Wks.Rows(i).Delete 'this will delete
the entire row
Wks.Rows(i).Resize(, 2).Delete
Shift:=xlShiftUp
End If
Next i
Next cell
End Sub
The only difference in the 2 is that the code that will
not work is positioned furthur down the worksheet. The
data is the exact same as well.
Whats wrong here?
Todd Huttenstine