Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert IF-statements by Script, very slow.


I try to fill a column with individual IF-statements in a VB macro in a
for-loop.
Something like:

Cells(row, 1).FormulaR1C1 = "=IF(bool,1,2)"
row = row + 1

It is much slower than inserting a constant statement.
I think the reason is, that Excel is going to calculate the result of
the IF-statement at the same time the macro inserts the formulas.
Is there a way to prevent Excel from automatically updating the cells
during the macro?

Thank you for your help so far.

Parity


--
Parity
------------------------------------------------------------------------
Parity's Profile: http://www.excelforum.com/member.php...o&userid=25023
View this thread: http://www.excelforum.com/showthread...hreadid=478724

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Insert IF-statements by Script, very slow.

Hi Parity,

Instead of looping try something like:

Cells(x, 1).Resize(y).FormulaR1C1 = " = Your Formula"

Where x = the first formula row and y = the number of rows to receive the
formula.


---
Regards,
Norman



"Parity" wrote in
message ...

I try to fill a column with individual IF-statements in a VB macro in a
for-loop.
Something like:

Cells(row, 1).FormulaR1C1 = "=IF(bool,1,2)"
row = row + 1

It is much slower than inserting a constant statement.
I think the reason is, that Excel is going to calculate the result of
the IF-statement at the same time the macro inserts the formulas.
Is there a way to prevent Excel from automatically updating the cells
during the macro?

Thank you for your help so far.

Parity


--
Parity
------------------------------------------------------------------------
Parity's Profile:
http://www.excelforum.com/member.php...o&userid=25023
View this thread: http://www.excelforum.com/showthread...hreadid=478724



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Insert IF-statements by Script, very slow.

Set a couple of Excel things off, screenupdating and calculation, before the
code

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

and set them back afterwards


Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Parity" wrote in
message ...

I try to fill a column with individual IF-statements in a VB macro in a
for-loop.
Something like:

Cells(row, 1).FormulaR1C1 = "=IF(bool,1,2)"
row = row + 1

It is much slower than inserting a constant statement.
I think the reason is, that Excel is going to calculate the result of
the IF-statement at the same time the macro inserts the formulas.
Is there a way to prevent Excel from automatically updating the cells
during the macro?

Thank you for your help so far.

Parity


--
Parity
------------------------------------------------------------------------
Parity's Profile:

http://www.excelforum.com/member.php...o&userid=25023
View this thread: http://www.excelforum.com/showthread...hreadid=478724



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
Script to insert Row Jeremy Excel Discussion (Misc queries) 2 April 19th 10 02:39 PM
Need VBA script to auto-insert value upon row insert Phil Excel Worksheet Functions 4 May 6th 08 02:41 PM
Excel vba script extremely slow persenena Excel Programming 2 July 5th 05 12:25 PM
Script to insert the next Friday Mark Langendoerfer Excel Programming 1 April 12th 05 09:57 PM
Script to insert the next Friday T Kirtley Excel Programming 0 April 12th 05 08:27 PM


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