Functions to return 2 values

  • Thread starter Thread starter nath
  • Start date Start date
N

nath

HI,

I have a sub routine (at the minute) that determines
the 'dimension' of data that is held. I.e. if a question
number has one result, then it is not classes as a group,
but if it has more than one result, i.e. Question 15, can
have Kitchen, Bathroon, Garden it will be classed as a
group and have a breadth and depth.

I have written the code to deduce the breadth and depth,
what i want to do is make this a function, so i can do
somehting like.

r = inputbox("Enter Question","")

dimension_data (r)

with dimension_data being the function and returning the
variables that are calculated in it, called length and
breadth.

Can this be done, so when dimension_data(7) is called it
will return the values 4,5 for example.

TIA

Nath.
 
Public Function Dimension_data(r As Range)
Dim varr(1 To 2)
varr(1) = r.Rows.Count
varr(2) = r.Columns.Count
Dimension_data = varr
End Function


Sub Howtocall()
Dim varr1 As Variant
Dim rng As Range
Set rng = Range("B9:Z21")
varr1 = Dimension_data(rng)
For i = LBound(varr1) To UBound(varr1)
MsgBox i & " " & varr1(i)
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top