View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_5_] GS[_5_] is offline
external usenet poster
 
Posts: 226
Default Deleting blank columns

Here's two ways:

Sub DeleteColumn()
With Cells(1, 1)
'If Application.WorksheetFunction.CountBlank(.EntireCo lumn) =
Rows.Count Then .EntireColumn.Delete
'If .Value = "" Then .EntireColumn.Delete
End With
End Sub

Watch for wordwrap as both 'If' constructs are single lines.

The 1st 'If' reflects your initial criteria of the column being blank.
It counts the blank cells in the 1st column and compares that to the
number of rows on the worksheet. If equal then the column is deleted.

The 2nd 'If' checks if "A1" is empty and if so deletes the column.

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc