Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Replacing a formula its too slow

Replacing formula to cells EXTREMELY slow
Hi!
I have the following code
------------------------------------------------------------------------------

Private Sub ToggleButton3_Click()
Dim i As Long
Dim Lastrow As Long

Application.ScreenUpdating = False
Lastrow = 1000

If ToggleButton3.Value = True Then
'Fill in the checking formula
For i = 0 To 5
Cells(4, i + 9).Formula = "=IF($A4="""",""""
,COUNTIF(INDEX('Check'!4:4,1,$AI$2):INDEX('Check'!
4:4,1,$AI$3)," & i & "))"
Next
Else
For i = 0 To 5
Cells(4, i + 9).Formula = "=IF($A4="""",""""
,COUNTIF(INDEX('unCheck'!4:4,1,$AI$2):INDEX('unChe
ck'!4:4,1,$AI$3)," & i & "))"
Next
End If

Range("I4:N" & Lastrow).FillDown
Application.ScreenUpdating = True

End Sub
---------------------------------------------------------------------------

This code replace a formula each time a toggle button is pressed.
The cells range that the formula is replaced are the I4 :N1000

Its working, but extremely SLOW (pentium3 at 800Mhz)

I have already tried the screenupdating to false and calculation to
manual but there's no effect.

Is there any suggestions making the code running faster ???

Thanks in advance
Stathis


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Replacing a formula its too slow

Hi Stathis,

I would suggest doing the tow flavours of countif once for each of your 5
columns, and then just refer to the result in your IF statement.
That should run about 500 times faster.

I do not see a application.Calculation=xlmanual statement in the sub ...

Charles
______________________
Decision Models
FastExcel 2.1 now available
www.DecisionModels.com

"stakar " wrote in message
...
Replacing formula to cells EXTREMELY slow
Hi!
I have the following code
--------------------------------------------------------------------------

----

Private Sub ToggleButton3_Click()
Dim i As Long
Dim Lastrow As Long

Application.ScreenUpdating = False
Lastrow = 1000

If ToggleButton3.Value = True Then
'Fill in the checking formula
For i = 0 To 5
Cells(4, i + 9).Formula = "=IF($A4="""",""""
,COUNTIF(INDEX('Check'!4:4,1,$AI$2):INDEX('Check'!
4:4,1,$AI$3)," & i & "))"
Next
Else
For i = 0 To 5
Cells(4, i + 9).Formula = "=IF($A4="""",""""
,COUNTIF(INDEX('unCheck'!4:4,1,$AI$2):INDEX('unChe
ck'!4:4,1,$AI$3)," & i & "))"
Next
End If

Range("I4:N" & Lastrow).FillDown
Application.ScreenUpdating = True

End Sub
--------------------------------------------------------------------------

-

This code replace a formula each time a toggle button is pressed.
The cells range that the formula is replaced are the I4 :N1000

Its working, but extremely SLOW (pentium3 at 800Mhz)

I have already tried the screenupdating to false and calculation to
manual but there's no effect.

Is there any suggestions making the code running faster ???

Thanks in advance
Stathis


---
Message posted from http://www.ExcelForum.com/



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
help on replacing this formula Abbey Normal Excel Discussion (Misc queries) 6 August 23rd 07 05:17 PM
Replacing formula James[_26_] Excel Programming 2 August 11th 04 03:10 AM
Replacing Formula James[_26_] Excel Programming 2 August 9th 04 09:30 PM
replacing value by formula monika Excel Programming 4 March 4th 04 01:50 PM
Replacing a value from a formula Squid[_2_] Excel Programming 1 February 14th 04 02:02 PM


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