Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Excel crash - bug macro?

Hi Al007,

If
Application.WorksheetFunction.CountA(Rng.Columns(R ).EntireColumn) = 0
Then


Should all be on one line:

If Application.WorksheetFunction.CountA(Rng.Columns(R ). _
EntireColumn) = 0
Then

If this is not your problem, then post the relevant error message and
indicate the code line that is highlighted on error.


---
Regards,
Norman



"al007" wrote in message
oups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Excel crash - bug macro?

Hi Al007,

Attempting to beat line wrap, the indicated code snippet should be one
line:

If Application.WorksheetFunction. _
CountA(Rng.Columns(R).EntireColumn) = 0 Then


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Al007,

If
Application.WorksheetFunction.CountA(Rng.Columns(R ).EntireColumn) = 0
Then


Should all be on one line:

If Application.WorksheetFunction.CountA(Rng.Columns(R ). _
EntireColumn) = 0
Then

If this is not your problem, then post the relevant error message and
indicate the code line that is highlighted on error.


---
Regards,
Norman



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Excel crash - bug macro?

Not a line wrap problem - it does not work in my personal.xls file - I
crash after use

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Excel crash - bug macro?

Hi Al007,

If this is not your problem, then post the relevant error message
and indicate the code line that is highlighted on error.



---
Regards,
Norman


"al007" wrote in message
oups.com...
Not a line wrap problem - it does not work in my personal.xls file - I
crash after use





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 crash when trying to add macro button to QAT Ron Excel Discussion (Misc queries) 2 August 17th 07 10:53 PM
Excel VBA macro crash Patrick[_12_] Excel Programming 4 June 13th 05 03:25 PM
Fixing a Macro-related Crash in Excel Danimagus[_5_] Excel Programming 1 June 6th 05 06:37 PM
Macro causes Excel to crash Edgar Thoemmes[_4_] Excel Programming 3 October 29th 04 05:17 PM
Excel crash when running macro Eamonn Excel Programming 4 September 22nd 04 08:05 AM


All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"