View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default delete columns based on value in one cell

Hi,

Why don't you clearcontents instead

Sub DeleteColumns()
If Range("IT1").Value = 65536 Then
Columns("A:D").ClearContents
End If
End Sub

Mike

"larrydave" wrote:

Excel 2003 - I am trying to delete columns A through D based on the value of
cell 1, column IT:

If cell 1, column IT = 65536, delete columns A through D

This is what I have come up with:

Sub DeleteColumns()

If Cells("1,IT") = "65536" Then
Columns("A:D").delete
End If

End Sub

I get a run time error 13, type mismatch.

I have tried using column numbers instead, but am still having no luck.

(huge file, lots of mixed data I'm filtering using columns IS and IT)

Thank you so much for any help you can give.