PC Review


Reply
Thread Tools Rate Thread

array formulas in vba help

 
 
=?Utf-8?B?TmVlZCBIZWxwIEZhc3Qh?=
Guest
Posts: n/a
 
      5th Apr 2007
I have a workbook with a range of array formulas or CSE formulas. They are
essentially averageif formulas. They are available in 2007 but this has to be
saved in xls format. So, I have done a CSE or Array formula with the
ctrl+shift+enter. My problem is copying and pasting my formulas into other
workbooks with vba and them keeping that format. Here is the part of my code
where I try to alleviate that problem.


Here is my array formula that comes from
basebook.Worksheets("NetWeatherResidualLookup").Range("B2:B3433").Formula:

"=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
Effect'!$C$2:$C$10000,""))"




Here is the code:

Set myrange = mybook.Worksheets("NetWeatherResidualLookup").Range_("B2:B3433")
averageifformula =
basebook.Worksheet_("NetWeatherResidualLookup").Range("B2:B3433").Formula
myrange.FormulaArray = averageifformula

Application.DisplayAlerts = False

mybook.Close ([True])


Basically it is copying the formulas from the basebook and pasting them into
mybook. The mybook is all of the workbooks in a folder. Can someone help me
with this? Right now it takes forever to paste the range and when I do, my
relative reference in the equation is even. Instead of it referencing cell
A1, A2 and A3, it is A2, A4 and A6. Any help would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      5th Apr 2007
Use FormulaArray not Formula, and embedded quotes within the formula string
have to be doubled up

"=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
Effect'!$C$2:$C$10000,""""))"

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Need Help Fast!" <(E-Mail Removed)> wrote in message
news:401B67BD-2F08-4EE4-9939-(E-Mail Removed)...
>I have a workbook with a range of array formulas or CSE formulas. They are
> essentially averageif formulas. They are available in 2007 but this has to
> be
> saved in xls format. So, I have done a CSE or Array formula with the
> ctrl+shift+enter. My problem is copying and pasting my formulas into other
> workbooks with vba and them keeping that format. Here is the part of my
> code
> where I try to alleviate that problem.
>
>
> Here is my array formula that comes from
> basebook.Worksheets("NetWeatherResidualLookup").Range("B2:B3433").Formula:
>
> "=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
> Effect'!$C$2:$C$10000,""))"
>
>
>
>
> Here is the code:
>
> Set myrange =
> mybook.Worksheets("NetWeatherResidualLookup").Range_("B2:B3433")
> averageifformula =
> basebook.Worksheet_("NetWeatherResidualLookup").Range("B2:B3433").Formula
> myrange.FormulaArray = averageifformula
>
> Application.DisplayAlerts = False
>
> mybook.Close ([True])
>
>
> Basically it is copying the formulas from the basebook and pasting them
> into
> mybook. The mybook is all of the workbooks in a folder. Can someone help
> me
> with this? Right now it takes forever to paste the range and when I do, my
> relative reference in the equation is even. Instead of it referencing cell
> A1, A2 and A3, it is A2, A4 and A6. Any help would be greatly appreciated.



 
Reply With Quote
 
=?Utf-8?B?TmVlZCBIZWxwIEZhc3Qh?=
Guest
Posts: n/a
 
      5th Apr 2007

Bob the equation is the equation that is on the sheet. It's not actually in
the vba. I call the function with [averageifformula =
> > basebook.Worksheet_("NetWeatherResidualLookup").Range("B2:B3433").Formula]. It is saying that it is pulling the formula out. If I put formularray instead of formula nothing gets pasted. When I use [myrange.FormulaArray = averageifformula] I am turning the formulas into array formulas in my worksheet. Thanks




"Bob Phillips" wrote:

> Use FormulaArray not Formula, and embedded quotes within the formula string
> have to be doubled up
>
> "=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
> Effect'!$C$2:$C$10000,""""))"
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Need Help Fast!" <(E-Mail Removed)> wrote in message
> news:401B67BD-2F08-4EE4-9939-(E-Mail Removed)...
> >I have a workbook with a range of array formulas or CSE formulas. They are
> > essentially averageif formulas. They are available in 2007 but this has to
> > be
> > saved in xls format. So, I have done a CSE or Array formula with the
> > ctrl+shift+enter. My problem is copying and pasting my formulas into other
> > workbooks with vba and them keeping that format. Here is the part of my
> > code
> > where I try to alleviate that problem.
> >
> >
> > Here is my array formula that comes from
> > basebook.Worksheets("NetWeatherResidualLookup").Range("B2:B3433").Formula:
> >
> > "=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
> > Effect'!$C$2:$C$10000,""))"
> >
> >
> >
> >
> > Here is the code:
> >
> > Set myrange =
> > mybook.Worksheets("NetWeatherResidualLookup").Range_("B2:B3433")
> > averageifformula =
> > basebook.Worksheet_("NetWeatherResidualLookup").Range("B2:B3433").Formula
> > myrange.FormulaArray = averageifformula
> >
> > Application.DisplayAlerts = False
> >
> > mybook.Close ([True])
> >
> >
> > Basically it is copying the formulas from the basebook and pasting them
> > into
> > mybook. The mybook is all of the workbooks in a folder. Can someone help
> > me
> > with this? Right now it takes forever to paste the range and when I do, my
> > relative reference in the equation is even. Instead of it referencing cell
> > A1, A2 and A3, it is A2, A4 and A6. Any help would be greatly appreciated.

>
>
>

 
Reply With Quote
 
=?Utf-8?B?TmVlZCBIZWxwIEZhc3Qh?=
Guest
Posts: n/a
 
      5th Apr 2007

Bob the equation is the equation that is on the sheet. It's not actually in
the vba. I call the function with [averageifformula =
basebook.Worksheet_("NetWeatherResidualLookup").Range("B2:B3433").Formula].
It is saying that it is pulling the formula out. If I put formularray instead
of formula nothing gets pasted. When I use [myrange.FormulaArray =
averageifformula] I am turning the formulas into array formulas in my
worksheet. Thanks



"Bob Phillips" wrote:

> Use FormulaArray not Formula, and embedded quotes within the formula string
> have to be doubled up
>
> "=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
> Effect'!$C$2:$C$10000,""""))"
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Need Help Fast!" <(E-Mail Removed)> wrote in message
> news:401B67BD-2F08-4EE4-9939-(E-Mail Removed)...
> >I have a workbook with a range of array formulas or CSE formulas. They are
> > essentially averageif formulas. They are available in 2007 but this has to
> > be
> > saved in xls format. So, I have done a CSE or Array formula with the
> > ctrl+shift+enter. My problem is copying and pasting my formulas into other
> > workbooks with vba and them keeping that format. Here is the part of my
> > code
> > where I try to alleviate that problem.
> >
> >
> > Here is my array formula that comes from
> > basebook.Worksheets("NetWeatherResidualLookup").Range("B2:B3433").Formula:
> >
> > "=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
> > Effect'!$C$2:$C$10000,""))"
> >
> >
> >
> >
> > Here is the code:
> >
> > Set myrange =
> > mybook.Worksheets("NetWeatherResidualLookup").Range_("B2:B3433")
> > averageifformula =
> > basebook.Worksheet_("NetWeatherResidualLookup").Range("B2:B3433").Formula
> > myrange.FormulaArray = averageifformula
> >
> > Application.DisplayAlerts = False
> >
> > mybook.Close ([True])
> >
> >
> > Basically it is copying the formulas from the basebook and pasting them
> > into
> > mybook. The mybook is all of the workbooks in a folder. Can someone help
> > me
> > with this? Right now it takes forever to paste the range and when I do, my
> > relative reference in the equation is even. Instead of it referencing cell
> > A1, A2 and A3, it is A2, A4 and A6. Any help would be greatly appreciated.

>
>
>

 
Reply With Quote
 
=?Utf-8?B?TmVlZCBIZWxwIEZhc3Qh?=
Guest
Posts: n/a
 
      5th Apr 2007
Thanks Bob, but I figured it out. Appreciate the help.

"Bob Phillips" wrote:

> Use FormulaArray not Formula, and embedded quotes within the formula string
> have to be doubled up
>
> "=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
> Effect'!$C$2:$C$10000,""""))"
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Need Help Fast!" <(E-Mail Removed)> wrote in message
> news:401B67BD-2F08-4EE4-9939-(E-Mail Removed)...
> >I have a workbook with a range of array formulas or CSE formulas. They are
> > essentially averageif formulas. They are available in 2007 but this has to
> > be
> > saved in xls format. So, I have done a CSE or Array formula with the
> > ctrl+shift+enter. My problem is copying and pasting my formulas into other
> > workbooks with vba and them keeping that format. Here is the part of my
> > code
> > where I try to alleviate that problem.
> >
> >
> > Here is my array formula that comes from
> > basebook.Worksheets("NetWeatherResidualLookup").Range("B2:B3433").Formula:
> >
> > "=AVERAGE(IF('Cnty Effect'!$A$2:$A$10000=NetWeatherResidualLookup!A2,'Cnty
> > Effect'!$C$2:$C$10000,""))"
> >
> >
> >
> >
> > Here is the code:
> >
> > Set myrange =
> > mybook.Worksheets("NetWeatherResidualLookup").Range_("B2:B3433")
> > averageifformula =
> > basebook.Worksheet_("NetWeatherResidualLookup").Range("B2:B3433").Formula
> > myrange.FormulaArray = averageifformula
> >
> > Application.DisplayAlerts = False
> >
> > mybook.Close ([True])
> >
> >
> > Basically it is copying the formulas from the basebook and pasting them
> > into
> > mybook. The mybook is all of the workbooks in a folder. Can someone help
> > me
> > with this? Right now it takes forever to paste the range and when I do, my
> > relative reference in the equation is even. Instead of it referencing cell
> > A1, A2 and A3, it is A2, A4 and A6. Any help would be greatly appreciated.

>
>
>

 
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
Re: Convert Array Formulas to Regular Formulas minyeh Microsoft Excel Worksheet Functions 0 21st Mar 2010 05:55 AM
Convert Array Formulas to Regular Formulas Domenick Microsoft Excel Worksheet Functions 4 19th Mar 2010 01:23 PM
Array formulas Lynda Microsoft Excel Worksheet Functions 3 25th Jun 2009 03:06 PM
array formulas Ray S. Microsoft Excel Misc 0 8th Aug 2008 08:15 PM
Array Formulas mkaake Microsoft Excel Worksheet Functions 3 27th Apr 2004 04:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:35 PM.