Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using a string as a formula (for an array)

Hi all,

I'm working with arrays within VB but would like the Excel user to be able
to specify basic formulas that can be used - i.e for each row, add column 1
to column 2 and store in column 3. Now, I have a way of converting the
"excel" formula to an "array" forumula in VB, however this formula is a text
string.

i.e. my entry in the third column is: "test_csv(1,1)+test_csv(1,2)" (as
text) whereas I want that to be the formula used and the entry to be the
result

is there anyway I can use this string to specify a formula?

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Using a string as a formula (for an array)

You can use the Evaluate method, but it has a number of quirks so needs
careful handling.

See http://www.decisionmodels.com/calcsecretsh.htm


Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group
http://www.decisionmodels.com/OZEUC.htm

"Muttley" wrote in message
...
Hi all,

I'm working with arrays within VB but would like the Excel user to be able
to specify basic formulas that can be used - i.e for each row, add column
1
to column 2 and store in column 3. Now, I have a way of converting the
"excel" formula to an "array" forumula in VB, however this formula is a
text
string.

i.e. my entry in the third column is: "test_csv(1,1)+test_csv(1,2)" (as
text) whereas I want that to be the formula used and the entry to be the
result

is there anyway I can use this string to specify a formula?

Thanks in advance!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Using a string as a formula (for an array)

Thanks for the quick reply! Evaluate doesn't seem to like the use of array
calcs (I get an error 2029) so looks like it's a no go. Maybe I'll use a
macro to get it to calculate in excel but this seems inefficient (I'm reading
in csv's that are too large for excel) Ah well!



"Charles Williams" wrote:

You can use the Evaluate method, but it has a number of quirks so needs
careful handling.

See http://www.decisionmodels.com/calcsecretsh.htm


Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group
http://www.decisionmodels.com/OZEUC.htm

"Muttley" wrote in message
...
Hi all,

I'm working with arrays within VB but would like the Excel user to be able
to specify basic formulas that can be used - i.e for each row, add column
1
to column 2 and store in column 3. Now, I have a way of converting the
"excel" formula to an "array" forumula in VB, however this formula is a
text
string.

i.e. my entry in the third column is: "test_csv(1,1)+test_csv(1,2)" (as
text) whereas I want that to be the formula used and the entry to be the
result

is there anyway I can use this string to specify a formula?

Thanks in advance!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Using a string as a formula (for an array)

A plus sign will append two string to each other , but the & is more
conventional

I would put in cell A3 the following
=test_csv(A1)&test_csv(B1)

then in VBA code

function test_csv(target as Range) as string

mystr = targtet.text
' add your code here
text_csv = mystr
end function


"Muttley" wrote:

Thanks for the quick reply! Evaluate doesn't seem to like the use of array
calcs (I get an error 2029) so looks like it's a no go. Maybe I'll use a
macro to get it to calculate in excel but this seems inefficient (I'm reading
in csv's that are too large for excel) Ah well!



"Charles Williams" wrote:

You can use the Evaluate method, but it has a number of quirks so needs
careful handling.

See http://www.decisionmodels.com/calcsecretsh.htm


Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group
http://www.decisionmodels.com/OZEUC.htm

"Muttley" wrote in message
...
Hi all,

I'm working with arrays within VB but would like the Excel user to be able
to specify basic formulas that can be used - i.e for each row, add column
1
to column 2 and store in column 3. Now, I have a way of converting the
"excel" formula to an "array" forumula in VB, however this formula is a
text
string.

i.e. my entry in the third column is: "test_csv(1,1)+test_csv(1,2)" (as
text) whereas I want that to be the formula used and the entry to be the
result

is there anyway I can use this string to specify a formula?

Thanks in advance!




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Using a string as a formula (for an array)

The Evaluate method will calculate an Excel formula string, which can be an
Excel array formula.
It will not evaluate visual basic syntax, which is maybe what you were
looking for (you can do that in Access using EVAL but not in Excel).


Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group
http://www.decisionmodels.com/OZEUC.htm

"Muttley" wrote in message
...
Thanks for the quick reply! Evaluate doesn't seem to like the use of
array
calcs (I get an error 2029) so looks like it's a no go. Maybe I'll use a
macro to get it to calculate in excel but this seems inefficient (I'm
reading
in csv's that are too large for excel) Ah well!



"Charles Williams" wrote:

You can use the Evaluate method, but it has a number of quirks so needs
careful handling.

See http://www.decisionmodels.com/calcsecretsh.htm


Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group
http://www.decisionmodels.com/OZEUC.htm

"Muttley" wrote in message
...
Hi all,

I'm working with arrays within VB but would like the Excel user to be
able
to specify basic formulas that can be used - i.e for each row, add
column
1
to column 2 and store in column 3. Now, I have a way of converting the
"excel" formula to an "array" forumula in VB, however this formula is a
text
string.

i.e. my entry in the third column is: "test_csv(1,1)+test_csv(1,2)" (as
text) whereas I want that to be the formula used and the entry to be
the
result

is there anyway I can use this string to specify a formula?

Thanks in advance!






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
String array issues. Need help... John Guderian Excel Programming 1 August 12th 05 08:00 PM
Tricky array formula issue - Using array formula on one cell, then autofilling down a range aspenbordr Excel Programming 0 July 27th 05 03:59 PM
Passing a String in Array to Range as String [email protected] Excel Programming 2 September 1st 04 01:13 AM
Convert a string to an array don Excel Programming 0 September 29th 03 05:08 PM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM


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