View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman[_2_] Mike Fogleman[_2_] is offline
external usenet poster
 
Posts: 206
Default delete columns based on value in one cell

What would happen if you copied Range("E:IR") to Range("A1")? Would that not
move all your data 4 columns left, leaving your formulas intact?

Mike F
"larrydave" wrote in message
...
My goal is to get yesterday's and today's dates into column A so I can do
some more filtering by dates (the file starts in June 08). I don't want to
have to loop through every fourth column to find my dates as the file is
just
going to continue to grow (which is why I'm using columns IS and IT). I
realize as time progresses, it may get so large as to not fit into an
excel
sheet at all. At that point I may have to split it across sheets, which
will
mean more weird programming.

What I would like happen is the tech people here where I work allow me to
just get rid of all the old data in the file I'm importing so my original
"sweet" program would work....but they are being stubborn and will just
continue to let it eat space in the drive.

Thanks for brainstorming with me, Mike!


"Mike H" wrote:

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.