View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default delete columns based on value in one cell

as an idea, see if this approach would work.

With Worksheets("Sheet1")

If .Cells(1, 254).Value = "123" Then
.Columns("A:D").EntireColumn.Delete
.Range(Cells(1, 249), Cells(1, 250)).Cut
.Paste Destination:=.Cells(1, 253)
End If

End With
--
jb


"larrydave" wrote:

That is awesome! Thank you.

There is one thing that I didn't forsee, however. My formulas in Columns IS
and IT also shifted left with the rest of the data. How can I keep my
formulas in those two columns?

Thanks so much!

"Simon Lloyd" wrote:


You have mixed up your ranges, this works

Code:
--------------------
If Cells(1, 254) = "123" Then
Columns("A:D").EntireColumn.Delete
End If
--------------------


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=38201