View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Column Delete based on String

Simply changing:

Range(cell).EntireColumn.Delete
to:
cell.EntireColumn.Delete

should do it.

RBS

"scott" wrote in message
...
I'm desperately tring to delete a column if a cell within a range equals
"TESTING". Below gives error "Method 'Range' of Object '_Global' failed".
I also need this selection to auto set to A1 to last non-blank cell on row
1. The cell coloring line works and is just there so I know I'm on the
right cell.

Any help in fixing these 2 actions may save a lot of gray hair.

Sub testSelectDelete()
Dim cell As Range

For Each cell In Selection
If Not IsEmpty(cell) And cell.Value = "TESTING" Then
cell.Interior.Color = RGB(255, 255, 192)
Range(cell).EntireColumn.Delete
End If
Next

End Sub