antaeusguy
Board Regular
- Joined
- Mar 8, 2010
- Messages
- 81
Hi.
In my worksheet, I have 1 row of data and the pattern looks like this:
Cell A1 B1 C1 D1 E1 ...
Value Y X Y X X ...
I want to delete the entire column if the value = X
I wrote this code:
I got an error message stating "Object required" and highlighted the statement "Set rng = rng.Next"
I tried to debug and figure out how to solve this but couldn't think of the root cause of the problem...
I hope someone can shine a light on this issue. Thanks in advance!
In my worksheet, I have 1 row of data and the pattern looks like this:
Cell A1 B1 C1 D1 E1 ...
Value Y X Y X X ...
I want to delete the entire column if the value = X
I wrote this code:
Code:
Sub testrng()
Dim rng As Range
Dim i As Integer
Set rng = [a1]
For i = 1 To 100
If rng.Value = "X" Then
rng.EntireColumn.Delete
End If
Set rng = rng.Next
Next i
End Sub
I got an error message stating "Object required" and highlighted the statement "Set rng = rng.Next"
I tried to debug and figure out how to solve this but couldn't think of the root cause of the problem...
I hope someone can shine a light on this issue. Thanks in advance!