Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Sloooow loop

I am using the following code and was supprised at how slow it ran.
Can anyone tell me a better (faster way)???

Dim WorkRange As Range

If Sheet4.Range("a51").Value = "" Then
Set WorkRange = Sheet4.Range("a55").End(xlUp).Offset(1, 0)
WorkRange.Offset(0, 0).Value = ufTrustEntry.tbDate.Value
WorkRange.Offset(0, 1).Value = ufTrustEntry.cbCustomer.Value
WorkRange.Offset(0, 2).Value = ufTrustEntry.cbAccount.Value
WorkRange.Offset(0, 3).Value = ufTrustEntry.cbTransaction.Value
WorkRange.Offset(0, 4).Value = ufTrustEntry.tbAmount.Value
WorkRange.Offset(0, 5).Value = ufTrustEntry.tbAddInfo.Value
Else
MsgBox "You have exceeded the limit of Current transactions, you must do
a 'New Day' to continue.", vbOKOnly + vbExclamation, "Data Limit exceeded"
ClearTrans
Exit Sub
End If

Set WorkRange = Nothing

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sloooow loop

The code shouldn't be slow. If you have formulas referring to the cells
being updated, that might be the culprit. Set calculation to manual

application.Calculation = xlManual
If Sheet4.Range("a51").Value = "" Then
Set WorkRange = Sheet4.Range("a55").End(xlUp).Offset(1, 0)
WorkRange.Offset(0, 0).Value = ufTrustEntry.tbDate.Value
WorkRange.Offset(0, 1).Value = ufTrustEntry.cbCustomer.Value
WorkRange.Offset(0, 2).Value = ufTrustEntry.cbAccount.Value
WorkRange.Offset(0, 3).Value = ufTrustEntry.cbTransaction.Value
WorkRange.Offset(0, 4).Value = ufTrustEntry.tbAmount.Value
WorkRange.Offset(0, 5).Value = ufTrustEntry.tbAddInfo.Value
Else
MsgBox "You have exceeded the limit of Current transactions, you must

do
a 'New Day' to continue.", vbOKOnly + vbExclamation, "Data Limit exceeded"
ClearTrans
Exit Sub
End If

Application.Calculation = xlAutomatic

--
Regards,
Tom Ogilvy



"Christy" wrote in message
...
I am using the following code and was supprised at how slow it ran.
Can anyone tell me a better (faster way)???

Dim WorkRange As Range

If Sheet4.Range("a51").Value = "" Then
Set WorkRange = Sheet4.Range("a55").End(xlUp).Offset(1, 0)
WorkRange.Offset(0, 0).Value = ufTrustEntry.tbDate.Value
WorkRange.Offset(0, 1).Value = ufTrustEntry.cbCustomer.Value
WorkRange.Offset(0, 2).Value = ufTrustEntry.cbAccount.Value
WorkRange.Offset(0, 3).Value = ufTrustEntry.cbTransaction.Value
WorkRange.Offset(0, 4).Value = ufTrustEntry.tbAmount.Value
WorkRange.Offset(0, 5).Value = ufTrustEntry.tbAddInfo.Value
Else
MsgBox "You have exceeded the limit of Current transactions, you must

do
a 'New Day' to continue.", vbOKOnly + vbExclamation, "Data Limit exceeded"
ClearTrans
Exit Sub
End If

Set WorkRange = Nothing



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Sloooow loop

Thanks Tom! I actually posted the wrong code but your answer was still
correct. The part that was giving me trouble was similar but included a
For-Next loop inside the If-Then.

Christy ;)

"Tom Ogilvy" wrote:

The code shouldn't be slow. If you have formulas referring to the cells
being updated, that might be the culprit. Set calculation to manual

application.Calculation = xlManual
If Sheet4.Range("a51").Value = "" Then
Set WorkRange = Sheet4.Range("a55").End(xlUp).Offset(1, 0)
WorkRange.Offset(0, 0).Value = ufTrustEntry.tbDate.Value
WorkRange.Offset(0, 1).Value = ufTrustEntry.cbCustomer.Value
WorkRange.Offset(0, 2).Value = ufTrustEntry.cbAccount.Value
WorkRange.Offset(0, 3).Value = ufTrustEntry.cbTransaction.Value
WorkRange.Offset(0, 4).Value = ufTrustEntry.tbAmount.Value
WorkRange.Offset(0, 5).Value = ufTrustEntry.tbAddInfo.Value
Else
MsgBox "You have exceeded the limit of Current transactions, you must

do
a 'New Day' to continue.", vbOKOnly + vbExclamation, "Data Limit exceeded"
ClearTrans
Exit Sub
End If

Application.Calculation = xlAutomatic

--
Regards,
Tom Ogilvy



"Christy" wrote in message
...
I am using the following code and was supprised at how slow it ran.
Can anyone tell me a better (faster way)???

Dim WorkRange As Range

If Sheet4.Range("a51").Value = "" Then
Set WorkRange = Sheet4.Range("a55").End(xlUp).Offset(1, 0)
WorkRange.Offset(0, 0).Value = ufTrustEntry.tbDate.Value
WorkRange.Offset(0, 1).Value = ufTrustEntry.cbCustomer.Value
WorkRange.Offset(0, 2).Value = ufTrustEntry.cbAccount.Value
WorkRange.Offset(0, 3).Value = ufTrustEntry.cbTransaction.Value
WorkRange.Offset(0, 4).Value = ufTrustEntry.tbAmount.Value
WorkRange.Offset(0, 5).Value = ufTrustEntry.tbAddInfo.Value
Else
MsgBox "You have exceeded the limit of Current transactions, you must

do
a 'New Day' to continue.", vbOKOnly + vbExclamation, "Data Limit exceeded"
ClearTrans
Exit Sub
End If

Set WorkRange = Nothing




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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
For Each Loop jbjtc Excel Discussion (Misc queries) 8 September 20th 07 01:28 PM
Updating range properties is so sloooow!!! Frank_Hamersley Excel Programming 9 June 19th 04 08:43 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


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

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

About Us

"It's about Microsoft Excel"