+ Reply to Thread
Results 1 to 7 of 7

How do I pass a textbox on a spreadsheet to a function

  1. #1
    Registered User
    Join Date
    07-09-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    6

    How do I pass a textbox on a spreadsheet to a function

    Hi Guys,

    Basically what I want to be able to do is to pass a textbox from an excel spreadsheet to a function and assign the text and font color of that textbox. I have this textbox on top of a chart to mark whether a goal was met based on chart data.

    Here's what I am trying to pass to the function:

    Please Login or Register  to view this content.
    I'm getting a compile error: "Expected: ="

    Here's the function that I'm using:

    Please Login or Register  to view this content.
    Thanks for your help.
    Last edited by ucchris77; 07-13-2010 at 10:22 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How do I pass a textbox on a spreadsheet to a function

    Are you are trying to use this in a worksheet cell?

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How do I pass a textbox on a spreadsheet to a function

    The way I would do it:

    Please Login or Register  to view this content.
    By the way: a Sub is a macro, not a function.

  4. #4
    Registered User
    Join Date
    07-09-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: How do I pass a textbox on a spreadsheet to a function

    No I'm using a VBA macro. This function is part of larger macro which is run automatically when the workbook is opened.

  5. #5
    Registered User
    Join Date
    07-09-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: How do I pass a textbox on a spreadsheet to a function

    Ah I made a mistake, you're right a sub isn't a function. I'm new to VBA.

    Thanks for your help snb that looks like it would work, but what I want to do is pass the textbox as a parameter into this subroutine. Is there no way to do that? I'm going for an object oriented approach.

    NOTE: Also this textbox is merely for displaying the letter it accepts input from the chart not the user. I actually wish there was something better to use than a textbox.
    Last edited by ucchris77; 07-09-2010 at 11:18 AM. Reason: Forgot to put something

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How do I pass a textbox on a spreadsheet to a function

    Either add a Call or drop the brackets

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-09-2010
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: How do I pass a textbox on a spreadsheet to a function

    Thanks, Andy that works perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1