I'm trying to write a script that will check the contents of a cell and if a match is found it deletes the line containing the original cell.
Here's what I have so far:
This gets an error 438 when trying to set the 'line' variable. I suspect it has something to do with the variable inside the variable but I am not sure how to correct it.
Any help would be greatly appreciated. Thanks in advance.
Here's what I have so far:
VBA Code:
Sub test()
Dim x As Long
x = 2
Dim format As Worksheet: Set format = Sheets("Formatting")
Dim pending As Worksheet: Set pending = Sheets("Pending")
Dim line As Range: Set line = ActiveWorkbook.format.Range(Cells(x, 1), Cells(x, 11))
Dim rng As Range: Set rng = ActiveWorkbook.pending.Range("A2", Range("A2").End(xlDown))
Dim txt As Range: Set txt = ActiveWorkbook.format.Range(format.Cells(x, 1))
Do While Sheets("Formatting").Cells(x, 1).Value <> ""
If Intersect(rng, txt) Then
line.Select
Selection.Delete xlShiftUp
Else
x = x + 1
End If
Loop
End Sub
This gets an error 438 when trying to set the 'line' variable. I suspect it has something to do with the variable inside the variable but I am not sure how to correct it.
Any help would be greatly appreciated. Thanks in advance.