View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Lakeuk Lakeuk is offline
external usenet poster
 
Posts: 5
Default Select and Delete Columns

The following code is an example that will work for you, may need
modifying if you have a large spreadsheet as my example only deletes
one column at a time.

Dave, Kendal


Sub test()
Cells.Select
Selection.Sort Key1:=Range("A3"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
Application.Goto Reference:="R3C1"
While IsEmpty(ActiveCell) = False
If ActiveCell = 0 Then
ActiveCell.EntireColumn.Delete
ElseIf ActiveCell 0 Then
ActiveCell.Offset(0, 1).Range("A1").Select
End If
Wend
End Sub






"jacqui" wrote in message ...
Rob,
Thanks for your suggestion. Unfortunately the i counter
doesn't work when the code finds a column to delete 'cause
what should be the next column to test becomes the current
column in the loop and then the counter increments again
so it's effectively skipping a column each time. That's
why I was going to work the loop from right to left rather
than left to right.
Can you help I'm still stuck with the syntax
Jacqui