Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Slow Macro Issue

Hello:

I have a macro that usually runs fairly quickly, but in this instance it is
running for around 45 seconds to a minute. It basically hides rows based on a
cell in a range that contains an IF statement to see if that row has a
certain name in it.

The code is this:

Sub HideVendorSummary()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
ActiveSheet.Unprotect

Dim HideCell As Range

Range("A14:A114").EntireColumn.Hidden = False
Range("A14:A114").EntireRow.Hidden = False
For Each HideCell In Range("A14:A114").Rows

If HideCell = "Y" Then
HideCell.EntireRow.Hidden = True
End If

Next HideCell

Range("A14:A114").EntireColumn.Hidden = True
Range("L:L").EntireColumn.Hidden = True
Range("G4").Select

ActiveSheet.Shapes("PMUPic").Visible = False
ActiveSheet.Shapes("GBBPic").Visible = False
ActiveSheet.Shapes("CMFPic").Visible = False
ActiveSheet.Shapes("CHD").Visible = True
ActiveSheet.Shapes("CVD").Visible = True

Range("S1").Value = "Y"
Range("F4").Select

ActiveWindow.ScrollColumn = 1

Application.Calculation = xlCalculationAutomatic
Application.Calculate
ActiveSheet.Protect

End Sub

I do not know why it is runing this slow, does anyone have any opinions. I
have read several sites about speeding up code or why code can run slow, but
as of yet have been unhelpful.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Slow Macro Issue

I ran your code and it didn't appear slow. Try leaving Excel and coming
back. Cleaned up below
Range("a14:a114") is ROWS not COLUMNs

Sub HideVendorSummary()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
ActiveSheet.Unprotect

Dim HideCell As Range

'Range("A14:A114").EntireColumn.Hidden = False
Columns(1).Hidden = False
Rows("1:114").Hidden = False
'Range("A14:A114").EntireRow.Hidden = False
For Each HideCell In Range("A14:A114")

If UCase(HideCell) = "Y" Then
HideCell.EntireRow.Hidden = True
End If

Next HideCell
Range("a1,L1").EntireColumn.Hidden = True
'Range("A14:A114").EntireColumn.Hidden = True
'Range("L:L").EntireColumn.Hidden = True
'Range("G4").Select
With ActiveSheet
.Shapes("PMUPic").Visible = False
.Shapes("GBBPic").Visible = False
.Shapes("CMFPic").Visible = False
.Shapes("CHD").Visible = True
.Shapes("CVD").Visible = True
End With
' ActiveSheet.Shapes("PMUPic").Visible = False
' ActiveSheet.Shapes("GBBPic").Visible = False
' ActiveSheet.Shapes("CMFPic").Visible = False
' ActiveSheet.Shapes("CHD").Visible = True
' ActiveSheet.Shapes("CVD").Visible = True

Range("S1").Value = "Y"
'Range("F4").Select

'ActiveWindow.ScrollColumn = 1

Application.Calculation = xlCalculationAutomatic
Application.Calculate
ActiveSheet.Protect

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"WBTKbeezy" wrote in message
...
Hello:

I have a macro that usually runs fairly quickly, but in this instance it
is
running for around 45 seconds to a minute. It basically hides rows based
on a
cell in a range that contains an IF statement to see if that row has a
certain name in it.

The code is this:

Sub HideVendorSummary()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
ActiveSheet.Unprotect

Dim HideCell As Range

Range("A14:A114").EntireColumn.Hidden = False
Range("A14:A114").EntireRow.Hidden = False
For Each HideCell In Range("A14:A114").Rows

If HideCell = "Y" Then
HideCell.EntireRow.Hidden = True
End If

Next HideCell

Range("A14:A114").EntireColumn.Hidden = True
Range("L:L").EntireColumn.Hidden = True
Range("G4").Select

ActiveSheet.Shapes("PMUPic").Visible = False
ActiveSheet.Shapes("GBBPic").Visible = False
ActiveSheet.Shapes("CMFPic").Visible = False
ActiveSheet.Shapes("CHD").Visible = True
ActiveSheet.Shapes("CVD").Visible = True

Range("S1").Value = "Y"
Range("F4").Select

ActiveWindow.ScrollColumn = 1

Application.Calculation = xlCalculationAutomatic
Application.Calculate
ActiveSheet.Protect

End Sub

I do not know why it is runing this slow, does anyone have any opinions. I
have read several sites about speeding up code or why code can run slow,
but
as of yet have been unhelpful.


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
Excel2007 Conditional Formatting Slow Performance Issue Michael F Excel Worksheet Functions 1 June 26th 09 05:42 PM
Slow Macro Frank Situmorang Excel Programming 7 June 30th 07 02:26 PM
Issue with code execution -- it is very slow robs3131 Excel Programming 7 June 8th 07 11:46 PM
slow macro John_A[_2_] Excel Programming 3 March 6th 07 06:36 PM
Macro help, very slow Scott Marcus Excel Programming 0 November 8th 06 05:39 PM


All times are GMT +1. The time now is 09:56 AM.

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"