View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
al007 al007 is offline
external usenet poster
 
Posts: 118
Default Excel crash - bug macro?

Is there any bug in the macro below - as i'm getting an error report
when i close my excel.

Thxs



Sub columnWidthSelection5()


Dim R As Long
Dim C As Range
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

If Selection.Columns.Count 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Columns
End If
For R = Rng.Columns.Count To 1 Step -1
If
Application.WorksheetFunction.CountA(Rng.Columns(R ).EntireColumn) = 0
Then
Rng.Columns(R).EntireColumn.Columnwidth = 0.5
End If
Next R

EndMacro:

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub