Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Abbie Cohen   on Nov 28 In MS Office Category.

  
Question Answered By: Devin Ross   on Nov 28

function  can only return a value or values. It can't change any cell
directly, just the one(s) that is is returning value(s) to. You could make your
function an array function, so that it can occupy multiple cells. For example:

Public Function boomLength(radius As Double, height As Double)
Dim vData(1 To 1, 1 To 2) As Variant
vData(1, 1) = (radius ^ 2 + height ^ 2) ^ 0.5
vData(1, 2) = "insert text  here"
boomLength = vData
End Function

Then, if entered as a simple function, it returns only the boomLength value.
But if array-entered (i.e. Ctrl-Shift-Enter) as a row and two columns, you'll
get both the boomLength value in the first column and the text in the second
column.

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on calling a sub routine Or get search suggestion and latest updates.


Tagged: