Column Delete based on String
When I said sort, I meant sort out!
--
HTH
Bob Phillips
"Bob Phillips" wrote in message
...
Scott,
To sort the code you need
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)
cell.EntireColumn.Delete
End If
Next
End Sub
But why do you test for not empty and has a value of "TESTING" (the second
can only mean tat it isn't empty), and why do you set the cell's colour,
then delete the whole column (thereby deleting the cell you have just
set)?
--
HTH
Bob Phillips
"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
|