View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Executor Executor is offline
external usenet poster
 
Posts: 74
Default Deleting Columns

Hi Robert,

You are close:

Sub DeleteBlankDataColumns(FromColumn As String, ThruColumn As String)
Dim nFirstRow As Long
Dim nLastRow As Long
Dim nFirstCol As Long
Dim nLastCol As Long
Dim nCol As Long
Dim sAddress As String
Dim rng As Range

nFirstCol = Range(FromColumn & "1").Column
nLastCol = Range(ThruColumn & "1").Column
With ActiveSheet.UsedRange
nLastRow = .Rows.Count + .Row - 1
nFirstRow = .Row
End With
Application.ScreenUpdating = False
For nCol = nLastCol To nFirstCol Step -1
Set rng = Range(Cells(nFirstRow, nCol), Cells(nLastRow, nCol))
If WorksheetFunction.CountBlank(rng) = rng.Count Then
rng.EntireColumn.Delete
End If
Next nCol
Application.ScreenUpdating = True
End Sub


Hoop this helps


Executor