Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Named formula VBA insert error

I'm not sure if this a Worksheet Function issue or a VBA issue
because it involves both...

I need to paste a named formula, using VBA into a vertical range of
cells. I need the formula to add the value of the previous cell (the
cell above the current cell) the result of a separate calculation in
the formula.

The VBA code is working and pasts the formula where I need it.

The "separate calculation" is working

In troubleshooting my problem I found:

If I write the formula directly into the first cell and then copy and
paste it manually into the rest of the range everything works fine.

Formula as written in A114 and also in the "Refers To:" block for
Name "BinSizeForm2"
=A113+INDIRECT($C$114&"BinSize"&$D$114)

As pasted in subsequent cells:
=A114+INDIRECT($C$114&"BinSize"&$D$114)
=A115+INDIRECT($C$114&"BinSize"&$D$114)
=A116+INDIRECT($C$114&"BinSize"&$D$114)
And so on... which works perfect

Putting "=BinSizeForm2" in each cell returns the correct results
also.

The problem occurs when the name is written to the range cells using
VBA; all cells end up with the same value (formula):
=Htestc!A113+INDIRECT(Htestc!$C$114&"BinSize"&Htes tc!$D$114)

Every cell starts with A113 instead of the previous cell reference.


Help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Named formula VBA insert error

this should have read:
I need the formula to add the value of the previous cell (the
cell above the current cell) TO the result of a separate calculation in
the formula.

:O


wrote:
I'm not sure if this a Worksheet Function issue or a VBA issue
because it involves both...

I need to paste a named formula, using VBA into a vertical range of
cells. I need the formula to add the value of the previous cell (the
cell above the current cell) the result of a separate calculation in
the formula.

The VBA code is working and pasts the formula where I need it.

The "separate calculation" is working

In troubleshooting my problem I found:

If I write the formula directly into the first cell and then copy and
paste it manually into the rest of the range everything works fine.

Formula as written in A114 and also in the "Refers To:" block for
Name "BinSizeForm2"
=A113+INDIRECT($C$114&"BinSize"&$D$114)

As pasted in subsequent cells:
=A114+INDIRECT($C$114&"BinSize"&$D$114)
=A115+INDIRECT($C$114&"BinSize"&$D$114)
=A116+INDIRECT($C$114&"BinSize"&$D$114)
And so on... which works perfect

Putting "=BinSizeForm2" in each cell returns the correct results
also.

The problem occurs when the name is written to the range cells using
VBA; all cells end up with the same value (formula):
=Htestc!A113+INDIRECT(Htestc!$C$114&"BinSize"&Htes tc!$D$114)

Every cell starts with A113 instead of the previous cell reference.


Help.


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
Named Range Used in Formula Error Ronald[_2_] Excel Discussion (Misc queries) 3 July 23rd 08 11:50 PM
Insert Function next to formula bar gives Run-time Error '50290' Nick Excel Discussion (Misc queries) 0 July 7th 08 03:41 PM
#REF error in named formula Gene Excel Worksheet Functions 2 November 24th 07 11:18 PM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
HELP! Lost data - need to insert formula but get error! Ed[_18_] Excel Programming 9 May 13th 04 10:30 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"