Darren Arnold
New Member
- Joined
- Jul 20, 2011
- Messages
- 10
OK, so I'm trying to return values for an object based on it's name.
Let's say it's a brick, and I call it as Brick("S") to say it's a standard brick.
Inside the function it determines the various dimensions of an "S" brick, I want to return those valuses without writing a function to return each individually.
So I want, from the Spreadsheet Cell to simply call it as say
=BRICK("S").LENGTH
and have it return a value in the cell.
I want to be able to do others like =BRICK("S").WIDTH and =BRICK("S").WIDTH*BRICK("S").HEIGHT
Now.. this is as far as I get:
I defined a type called Dimensions in Visual Basic:
Public Type Dimensions
Area As Double
Length As Double
Height As Double
Volume As Double
Width As Double
End Type
So far so good.
I scratched up a test function:
Function Brick() As Dimensions
Brick.Area = 0
Brick.Length = 230
Brick.Height = 0
Brick.Volumne = 0
Brick.Width = 0
End Function
If I call it as =Brick.Length in the spreadhseet it pops up the VB windows gives me:
"User defined type not defined"
If I call it as Brick().Length it says the formula I typed contains an error
Help!!!
I think logically I'm on the right track but having one of those derailments you have at 4am when you forget to factor in that sine can go negative or that some twit put a 0 where it shouldn't be and everything tried to divide by it.
From
Let's say it's a brick, and I call it as Brick("S") to say it's a standard brick.
Inside the function it determines the various dimensions of an "S" brick, I want to return those valuses without writing a function to return each individually.
So I want, from the Spreadsheet Cell to simply call it as say
=BRICK("S").LENGTH
and have it return a value in the cell.
I want to be able to do others like =BRICK("S").WIDTH and =BRICK("S").WIDTH*BRICK("S").HEIGHT
Now.. this is as far as I get:
I defined a type called Dimensions in Visual Basic:
Public Type Dimensions
Area As Double
Length As Double
Height As Double
Volume As Double
Width As Double
End Type
So far so good.
I scratched up a test function:
Function Brick() As Dimensions
Brick.Area = 0
Brick.Length = 230
Brick.Height = 0
Brick.Volumne = 0
Brick.Width = 0
End Function
If I call it as =Brick.Length in the spreadhseet it pops up the VB windows gives me:
"User defined type not defined"
If I call it as Brick().Length it says the formula I typed contains an error
Help!!!
I think logically I'm on the right track but having one of those derailments you have at 4am when you forget to factor in that sine can go negative or that some twit put a 0 where it shouldn't be and everything tried to divide by it.
From