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: 46
Default Same VBA code, different run time

Hello all,

Following code works well at daytime. It usually took less
then 1 mins. However, when I scheduled it running at
night, it usually took more then 10 mins. The PC is
desktop, opeation system is Win2000, Excel2000. The main
difference between day and night is nobody touch the desk
PC at night. I have setup the power alway onn, but no
help. Does anybody have idea how to fix it? Thanks a lot!

Sub Get_Data()

Dim d1 As Range
Dim d2 As Range
dim i as long
Dim j As Integer
Dim k As Integer

i=3000
Sheets("Query5").Select
Set d1 = Range(Cells(2, 3), Cells(i - 1, 3))

Sheets("Query2").Select
Columns("C:C").Select
Selection.ClearContents
Columns("J:J").Select
Selection.ClearContents

For j = 2 To 20000
If Cells(j, 4) = "" Then
Exit For
End If
Cells(j, 3) = Mid(Cells(j, 4), 1, 8)
With d1
Set d2 = .Find(Cells(j, 4), LookIn:=xlValue,
lookat:=xlWhole)
End With
If Not d2 Is Nothing Then
Cells(j, 10) = 0
Else
Cells(j, 10) = 1
End If
Next
Columns("C:J").Select
Selection.Sort Key1:=Range("J1"), Order1:=xlAscending,
Key2:=Range("I1") _
, Order2:=xlDescending, Key3:=Range("D1"),
Order3:=xlDescending, _
Header:=xlYes, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom
Range("C1").Select
End Sub


Best Regards

Bill



 
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 with VBA code Dale G[_2_] Excel Discussion (Misc queries) 8 September 23rd 09 11:22 PM
Time code albertmb Excel Discussion (Misc queries) 0 February 23rd 09 11:59 AM
smpte time code KO_the_Kid Excel Discussion (Misc queries) 2 September 15th 08 09:59 AM
TIME CLOCK CODE Jase Excel Discussion (Misc queries) 0 April 29th 08 06:46 PM
Code for entering time - trying again Denise Excel Discussion (Misc queries) 4 September 29th 05 08:37 PM


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