LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Run Time Issue

Hello. I am running some code that clears a range of cells on
multiple sheets, then populates the same sheets with data being pulled
from a database-like worksheet. My question is this: Sometimes when
I run the code, it takes 20 seconds. Majority of the time I run the
code it takes 6 minutes! IS there data in a cache or something that
is forcing things to run so slowly? Usually, when I first open the
file and the sheets are already blank, it runs quickly. If I run it
again when the sheets are already populated, it takes forever! So I
thought it was just the sheer size of the file after being populated
that slowed things. BUT, then I selected every sheet, and hit the
home key. And when I ran the code, it ran in 20 seconds! I am SO
confused!! Anyone have any ideas on how to get the code to
consistently run quickly? The code is below. Thanks so much!!

Sub Run_Forecast()
Clear
Pop_Forecast
End Sub

Sub Clear()

Dim sh As Worksheet

Application.ScreenUpdating = False

clrarray = Array("Forecast", "LMU", "Kit", "SMLC", "WLG", "SMLC Cab",
"Serv Cab", "Ntwk Kit", _
"TDAX", "EMS", "SCOUT", "Dir Coup")

For Each sh In ActiveWorkbook.Worksheets(clrarray)
' Sheets("SMLC Cab").Range("A1").Select
' sh.Range("A1").Select
sh.Range("A5:EC500").ClearContents
Next sh
Application.ScreenUpdating = True

End Sub

Sub Pop_Forecast()

Dim shtarray As Sheets
Dim frng As Range
Dim sh As Worksheet

Application.ScreenUpdating = False

Set shtarray = Sheets(Array("LMU", "Kit", "SMLC", "WLG", "SMLC Cab",
"Serv Cab", "Ntwk Kit", _
"TDAX", "EMS", "SCOUT", "Dir Coup"))

shtarray.Select
Sheets("LMU").Activate

'Copy Formula
Range("A2:EC2").Copy

Set frng = Range("A5:EC" & Data.Range("b65536").End(xlUp).Row)
frng.Select
Selection.PasteSpecial Paste:=xlPasteFormulas

'Consolidate2
Forecast.Range("A5").Consolidate Sources:=Array( _
"'LMU'!R5C5:R500C133" _
, "'Kit'!R5C5:R500C133" _
, "'SMLC'!R5C5:R500C133" _
, "'WLG'!R5C5:R500C133" _
, "'SMLC Cab'!R5C5:R500C133" _
, "'Serv Cab'!R5C5:R500C133" _
, "'Ntwk Kit'!R5C5:R500C133" _
, "'TDAX'!R5C5:R500C133" _
, "'EMS'!R5C5:R500C133" _
, "'SCOUT'!R5C5:R500C133" _
, "'Dir Coup'!R5C5:R500C133" _
), Function:=xlSum, TopRow:=False, LeftColumn:=True,
CreateLinks:=False

Forecast.Activate

Application.ScreenUpdating = True

End Sub
 
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
Time Conversion issue Farias Excel Discussion (Misc queries) 6 August 1st 08 03:47 PM
Excel time conversion issue benny Excel Discussion (Misc queries) 4 October 11th 07 09:10 PM
Time issue with Day Format K1KKKA Excel Discussion (Misc queries) 1 June 6th 07 10:24 AM
Military Time Issue vldavis809 Excel Discussion (Misc queries) 5 August 14th 06 08:05 PM
Time on the X Axis Issue Dave Charts and Charting in Excel 4 March 3rd 06 05:34 PM


All times are GMT +1. The time now is 08:45 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"