Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using user function (vba) with sqrt(array)-only first answer

Hello,

I have written an Excel spreadsheet that has a list of formulae. The
formulae perform array calculations on a 10 by 12 matrix. A formula is chosen
by the user. The spreadsheet calculates the formula using a vba function like

Function EVAL2(R)
EVAL2 = Application.Evaluate(R.Text)
End Function

I have a formula of the form: sqrt(x) where x is an array. I am expecting
the result to be the sqrt root of each number in x, but the result array is
full of the square of the first number in x. The above vba function works
fine for other formulae. I am confused why the sqrt root function would cause
problems. If I manually put the formula into a range of cells and press
ctrl-shift enter, the sqrt root formula works fine. It seems to fail with the
..evaluate function in vba.

Does anyone have any suggestions to get my evaluate vba function to properly
calculate the sqrt of an array (with the result being the square root of each
number in the array) or a workaround.

Thanks for the help everyone.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Using user function (vba) with sqrt(array)-only first answer

Range("F19").Resize(3,2).Value = Evaluate("(B4:C6)^.5")

worked for me. Does that give you some ideas.

--
Regards,
Tom Ogilvy


"Awill" wrote:

Hello,

I have written an Excel spreadsheet that has a list of formulae. The
formulae perform array calculations on a 10 by 12 matrix. A formula is chosen
by the user. The spreadsheet calculates the formula using a vba function like

Function EVAL2(R)
EVAL2 = Application.Evaluate(R.Text)
End Function

I have a formula of the form: sqrt(x) where x is an array. I am expecting
the result to be the sqrt root of each number in x, but the result array is
full of the square of the first number in x. The above vba function works
fine for other formulae. I am confused why the sqrt root function would cause
problems. If I manually put the formula into a range of cells and press
ctrl-shift enter, the sqrt root formula works fine. It seems to fail with the
.evaluate function in vba.

Does anyone have any suggestions to get my evaluate vba function to properly
calculate the sqrt of an array (with the result being the square root of each
number in the array) or a workaround.

Thanks for the help everyone.

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
Passing an array in a user defined function Peter M Excel Programming 5 June 27th 08 10:45 PM
User Defined Array Function Pflugs Excel Programming 6 July 31st 07 07:46 PM
We have SQRT. But what is the function for other roots - cubed ro. ACC Excel Worksheet Functions 7 March 2nd 05 07:37 PM
Creating a User Defined Array Function Jeff Mason Excel Programming 6 November 24th 04 07:43 PM
Array of 100X250 as return of a user defined function? Andersson Excel Programming 6 May 29th 04 07:06 AM


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