Hi,
Can anyone look into this? It is not working.
Basically, what I need is to delete every "Test" in a specific range that may change based on Range("A1").
If my understanding is correct, I wanted to set it up in Row 2 up to the last row, and any column based on A1 Value.
Set Function Last Row
Thanks in advance!!!
Can anyone look into this? It is not working.
Basically, what I need is to delete every "Test" in a specific range that may change based on Range("A1").
If my understanding is correct, I wanted to set it up in Row 2 up to the last row, and any column based on A1 Value.
HTML:
Sub TEST()
Dim cl As Range
Dim Cell As Range
Dim RngA As Range
Dim RngB As Range
LastRow = findLastRow(Sheets("Sheet1"))
Set RngA = Cell(2, Range("A1").Value)
Set RngB = Cell(2, LastRow)
For Each cl In Range(RngA, RngB)
If cl.Value = "Test" Then
cl.EntireRow.Delete
Else
End If
Next cl
End Sub
Set Function Last Row
HTML:
Function findLastRow(sheet As Worksheet) As Integer
Set r = sheet.Cells.Find("*", sheet.Range("A1"), xlFormulas, , xlByRows, xlPrevious)
If Not r Is Nothing Then
findLastRow = r.Row
Else
findLastRow = 0
End If
End Function
Thanks in advance!!!