PC Review


Reply
Thread Tools Rate Thread

Delay when writing cell information to Excel from VBA Macro

 
 
Dick HSV
Guest
Posts: n/a
 
      23rd Dec 2008
When I loop through in VBA setting a value for a variable the loop goes
fast. When I use cell(i,j).value to put the value in a cell there is about a
1 second delay between each cell. For 250 cells it is a long wait. Is there
any way to control this wait?
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      23rd Dec 2008
add
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

to the beginning of your code

and

Application.ScreenUpdating = true
Application.Calculation = xlCalculationAutomatic

at the end

--


Gary

"Dick HSV" <Dick (E-Mail Removed)> wrote in message
news:33D52851-B982-4C85-A507-(E-Mail Removed)...
> When I loop through in VBA setting a value for a variable the loop goes
> fast. When I use cell(i,j).value to put the value in a cell there is about a
> 1 second delay between each cell. For 250 cells it is a long wait. Is there
> any way to control this wait?



 
Reply With Quote
 
Dick HSV
Guest
Posts: n/a
 
      23rd Dec 2008
Gary,

Thanks alot. New to Excel macros - was stumped.

Dick HSV

"Gary Keramidas" wrote:

> add
> Application.ScreenUpdating = False
> Application.Calculation = xlCalculationManual
>
> to the beginning of your code
>
> and
>
> Application.ScreenUpdating = true
> Application.Calculation = xlCalculationAutomatic
>
> at the end
>
> --
>
>
> Gary
>
> "Dick HSV" <Dick (E-Mail Removed)> wrote in message
> news:33D52851-B982-4C85-A507-(E-Mail Removed)...
> > When I loop through in VBA setting a value for a variable the loop goes
> > fast. When I use cell(i,j).value to put the value in a cell there is about a
> > 1 second delay between each cell. For 250 cells it is a long wait. Is there
> > any way to control this wait?

>
>
>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      23rd Dec 2008
Also, read the range directly into a VB array, and if necessary, loop
through the array in memory. Then write the entire array to a range in one
step.

Sample Usage:

Reading:
Dim vArray As Variant ' must be "variant" to read range into VBA array
vArray = ActiveSheet.Range("A110").Value

Writing:
' can be array of any variable type
ActiveSheet.Range("A110").Value = myArray

This will produce a great improvement in execution speed, particularly
writing back to the sheet.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"Gary Keramidas" <GKeramidasAtMsn.com> wrote in message
news:(E-Mail Removed)...
> add
> Application.ScreenUpdating = False
> Application.Calculation = xlCalculationManual
>
> to the beginning of your code
>
> and
>
> Application.ScreenUpdating = true
> Application.Calculation = xlCalculationAutomatic
>
> at the end
>
> --
>
>
> Gary
>
> "Dick HSV" <Dick (E-Mail Removed)> wrote in message
> news:33D52851-B982-4C85-A507-(E-Mail Removed)...
>> When I loop through in VBA setting a value for a variable the loop goes
>> fast. When I use cell(i,j).value to put the value in a cell there is
>> about a
>> 1 second delay between each cell. For 250 cells it is a long wait. Is
>> there
>> any way to control this wait?

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help writing Excel macro to solve a cell in each row of a spreadsheet Chris Microsoft Excel Programming 5 10th Sep 2005 01:39 AM
Writing a macro to copy first cell down until next cell has data Gerald Microsoft Excel Programming 1 10th Aug 2005 10:06 PM
When writing a macro in excel workbook, how do I refer to ea cell =?Utf-8?B?RGlhbmEgQmFydHo=?= Microsoft Excel Programming 1 7th Jul 2005 09:51 PM
writing information from a userform to an excel sheet =?Utf-8?B?bWlrZQ==?= Microsoft Excel Programming 1 28th Jun 2005 08:57 PM
Writing variable from a Macro to a Cell Parker Microsoft Excel Programming 5 28th Sep 2003 03:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:19 PM.