Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 349379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:27:10+00:00 2026-05-12T11:27:10+00:00

This is for Excel and VBA. Assume that BondClass has been properly defined in

  • 0

This is for Excel and VBA. Assume that BondClass has been properly defined in a Class Module. I get a #VALUE! when I type “=GetBondPrincipal()” into an Excel cell. Have I done something syntactically wrong or is this just not possible in Excel/VBA? I ask because what I really want to do is this:
Return a User Defined Data Type in an Excel Cell

but am unable to find a solution. So at the very least, I want to know if what I want to do below is possible.


Option Explicit

Function InitializeBond(ir As Double, p As Double) As BondClass Dim mybond As BondClass Set mybond = New BondClass Call mybond.Initialize(ir, p) InitializeBond = mybond End Function

Function GetBondPrincipal() Dim b As BondClass Set b = New BondClass b = InitializeBond(0.03, 100) //the code quits here, //it doesn't like the BondClass return type? GetBondPrincipal = b.GetPrincipal() End Function

I know that in the example I have provided, I don't have to call InitializeBond and can simply type "Call b.Initialize(.03,100)". The code will work fine if I do this. But I can't seem to be able to get a UDF to return a type other than the built-in types. Any way to do any of this? Do I have to define assignment for non-built-in types?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:27:11+00:00Added an answer on May 12, 2026 at 11:27 am

    Hint: use “SET”.

    (most common error made by VB programmers in VB6 and VBA).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel VBA module calling a C# COM dll. Sometimes, I get
I have created an Excel 2003 add-in that uses the CLR 2.0 and this
VBA is a programming language so I'll assume this question is ok on SO.
I'm an Excel VBA newbie. How to change the value of the specified cell
a standard loop in Excel VBA goes like this: dim i as integer for
I'm automating ie from within Excel VBA like this, in part Set ie =
I am trying to create a function for excel-VBA. This function is used to
There's this Excel file I want users to be able to download from my
I have an Excel Spreadsheet like this id | data for id | more
I have two columns in Excel, like this: A B 0.5 0.4 0.6 0.59

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.