OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Hello and thanks in advance. Please let me know if you know how to fix this error.
My objective is to Loop through a column and delete any rows if the cell contains a partial match of values stored in an array.
Currently I am getting the error "Compile error: Type mismatch" on the following line of code specifically "ArrayPartial" (i.e. that's what gets highlighted for the error).
My full code:
My objective is to Loop through a column and delete any rows if the cell contains a partial match of values stored in an array.
Currently I am getting the error "Compile error: Type mismatch" on the following line of code specifically "ArrayPartial" (i.e. that's what gets highlighted for the error).
VBA Code:
If InStr(Cells(i, "C").Value, ArrayPartial, vbCompare) > 0 Then
My full code:
VBA Code:
Sub PartialMatchTest()
Dim RowLast As Long
Dim i As Long
Dim ArrayPartial() As Variant
RowLast = Cells(Rows.Count, "C").End(xlUp).Row
ReDim ArrayPartial(1 To 2)
ArrayPartial(1) = "https"
ArrayPartial(2) = "TTY"
For i = RowLast To 9 Step -1
If InStr(Cells(i, "C").Value, ArrayPartial, vbCompare) > 0 Then
Rows(i).EntireRow.Delete
End If
Next i
End Sub