Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Using rng.Value & RefersToRange to pass data between worksheets - SLOW!

I am writing a VBA application that identifies a named cell in Workbook1 and
then passes a value from an Array in Workbook2 to the named cells in
Workbook1. There are from 1 to 10 items in the Array. When all the items
have been passed, Workbook1 is recalculated and a named range is passed back
to Workbook2. The code works fine, but it is VERY SLOW. Can someone
suggest an alternative method for passing the Array data into the named
cells?

The code I am using looks like this:

Public uNameArray()
ReDim uNameArray(1 to 1, 1 to NumberOfArrayItems)

For y = 1 to NumberOfArrayItems
'Get the cell name from the Array
uName = uNameArray(1, y)

'Set the value of the named cell in Workbook 1 equal to SomeVAlue
Set rng.Value = Workbook1.Names(uName).RefersToRange
rng.Value = SomeValue

Next y

I would appreciate any help from the group.

Frank


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using rng.Value & RefersToRange to pass data between worksheets - SLOW!

Turn off calculation until you finish passing your values.

--
Regards,
Tom Ogilvy

"Frank & Pam Hayes" wrote in message
news:Fwn6d.17171$M45.16971@trndny09...
I am writing a VBA application that identifies a named cell in Workbook1

and
then passes a value from an Array in Workbook2 to the named cells in
Workbook1. There are from 1 to 10 items in the Array. When all the items
have been passed, Workbook1 is recalculated and a named range is passed

back
to Workbook2. The code works fine, but it is VERY SLOW. Can someone
suggest an alternative method for passing the Array data into the named
cells?

The code I am using looks like this:

Public uNameArray()
ReDim uNameArray(1 to 1, 1 to NumberOfArrayItems)

For y = 1 to NumberOfArrayItems
'Get the cell name from the Array
uName = uNameArray(1, y)

'Set the value of the named cell in Workbook 1 equal to SomeVAlue
Set rng.Value = Workbook1.Names(uName).RefersToRange
rng.Value = SomeValue

Next y

I would appreciate any help from the group.

Frank




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Using rng.Value & RefersToRange to pass data between worksheets - SLOW!

Tom,

I should have been more explicit, but I do have this on an earlier line:

Application.Calculation = xlCalculateManual

Any other thoughts?



"Tom Ogilvy" wrote in message
...
Turn off calculation until you finish passing your values.

--
Regards,
Tom Ogilvy

"Frank & Pam Hayes" wrote in message
news:Fwn6d.17171$M45.16971@trndny09...
I am writing a VBA application that identifies a named cell in Workbook1

and
then passes a value from an Array in Workbook2 to the named cells in
Workbook1. There are from 1 to 10 items in the Array. When all the
items
have been passed, Workbook1 is recalculated and a named range is passed

back
to Workbook2. The code works fine, but it is VERY SLOW. Can someone
suggest an alternative method for passing the Array data into the named
cells?

The code I am using looks like this:

Public uNameArray()
ReDim uNameArray(1 to 1, 1 to NumberOfArrayItems)

For y = 1 to NumberOfArrayItems
'Get the cell name from the Array
uName = uNameArray(1, y)

'Set the value of the named cell in Workbook 1 equal to SomeVAlue
Set rng.Value = Workbook1.Names(uName).RefersToRange
rng.Value = SomeValue

Next y

I would appreciate any help from the group.

Frank






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using rng.Value & RefersToRange to pass data between worksheets - SLOW!

Application.Calculation = xlCalculateManual


I assume that was a typo in your email:

? xlCalculateManual

? xlCalculationManual
-4135

xlCalculationManual would be the correct constant.


If you have to put values in a bunch of different non-contiguous cells, I am
not sure how else you would approach it but by identifying each of the
locations and placing the value.


--
Regards,
Tom Ogilvy


"Frank & Pam Hayes" wrote in message
news:QHn6d.3952$6f.490@trndny02...
Tom,

I should have been more explicit, but I do have this on an earlier line:

Application.Calculation = xlCalculateManual

Any other thoughts?



"Tom Ogilvy" wrote in message
...
Turn off calculation until you finish passing your values.

--
Regards,
Tom Ogilvy

"Frank & Pam Hayes" wrote in message
news:Fwn6d.17171$M45.16971@trndny09...
I am writing a VBA application that identifies a named cell in

Workbook1
and
then passes a value from an Array in Workbook2 to the named cells in
Workbook1. There are from 1 to 10 items in the Array. When all the
items
have been passed, Workbook1 is recalculated and a named range is passed

back
to Workbook2. The code works fine, but it is VERY SLOW. Can someone
suggest an alternative method for passing the Array data into the named
cells?

The code I am using looks like this:

Public uNameArray()
ReDim uNameArray(1 to 1, 1 to NumberOfArrayItems)

For y = 1 to NumberOfArrayItems
'Get the cell name from the Array
uName = uNameArray(1, y)

'Set the value of the named cell in Workbook 1 equal to SomeVAlue
Set rng.Value = Workbook1.Names(uName).RefersToRange
rng.Value = SomeValue

Next y

I would appreciate any help from the group.

Frank








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Using rng.Value & RefersToRange to pass data between worksheets - SLOW!

Tom,

It was a typo ... you are correct. I tested the code further and it does
not seem to be the calculation that is slowing it down. Rather the Set rng
and and rng.value lines are what is taking all the time. Since I cycle
through this code for three possible values for every combination of up to 9
varaibles (3 ^ 9), this is killing the application. I will keep working on
it!

Frank


"Tom Ogilvy" wrote in message
...
Application.Calculation = xlCalculateManual



I assume that was a typo in your email:

? xlCalculateManual

? xlCalculationManual
-4135

xlCalculationManual would be the correct constant.


If you have to put values in a bunch of different non-contiguous cells, I
am
not sure how else you would approach it but by identifying each of the
locations and placing the value.


--
Regards,
Tom Ogilvy


"Frank & Pam Hayes" wrote in message
news:QHn6d.3952$6f.490@trndny02...
Tom,

I should have been more explicit, but I do have this on an earlier line:

Application.Calculation = xlCalculateManual

Any other thoughts?



"Tom Ogilvy" wrote in message
...
Turn off calculation until you finish passing your values.

--
Regards,
Tom Ogilvy

"Frank & Pam Hayes" wrote in message
news:Fwn6d.17171$M45.16971@trndny09...
I am writing a VBA application that identifies a named cell in

Workbook1
and
then passes a value from an Array in Workbook2 to the named cells in
Workbook1. There are from 1 to 10 items in the Array. When all the
items
have been passed, Workbook1 is recalculated and a named range is
passed
back
to Workbook2. The code works fine, but it is VERY SLOW. Can someone
suggest an alternative method for passing the Array data into the
named
cells?

The code I am using looks like this:

Public uNameArray()
ReDim uNameArray(1 to 1, 1 to NumberOfArrayItems)

For y = 1 to NumberOfArrayItems
'Get the cell name from the Array
uName = uNameArray(1, y)

'Set the value of the named cell in Workbook 1 equal to SomeVAlue
Set rng.Value = Workbook1.Names(uName).RefersToRange
rng.Value = SomeValue

Next y

I would appreciate any help from the group.

Frank










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
Excel 2007 slow changing between worksheets [email protected] Excel Discussion (Misc queries) 0 July 5th 08 12:07 PM
Pass word protecting multipul worksheets within a workbook Terrie Excel Discussion (Misc queries) 1 December 31st 07 09:23 PM
Pass array of worksheets to ActiveX DLL (VB6) Hank Scorpio Excel Programming 25 June 21st 04 10:53 AM
slow sorting worksheets crew3407[_7_] Excel Programming 3 May 6th 04 02:36 PM
How do I pass a worksheets name to function? Phillips Excel Programming 2 December 11th 03 12:19 PM


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