+ Reply to Thread
Results 1 to 6 of 6

Passing name of shape to custom function

  1. #1
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Passing name of shape to custom function

    Help! This has been driving me mad for too long. And it should be stunningly simple but I cannot get it right.

    What I want to do is create a custom function that will allow me to pass the name of a shape to it so that I can then pick up the text in it. So for instance I have shape opt_P1 and I'd like to pick out the text in it using a formula. Something like:

    Please Login or Register  to view this content.
    Or something like that - seeing as it fails miserably if I use =get_box_state(opt_P1).

    Any tips to get me out of my own hell?

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Passing name of shape to custom function


    Obviously : as your actual code passes the shape in variable 'box' so just use this variable to refer this shape ‼

    If you really just want to pass the name, so a string then obviously set the variable as String !

    But as any shape is attached to a worksheet, so if you just pass the name do not forget to hard code the worksheet before Shapes …

  3. #3
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Passing name of shape to custom function

    I think this si what you mean:
    Please Login or Register  to view this content.
    If so that still gives a #VALUE error. So there is something wrong in my get_box_status line. I cannot figure out what it is though. Is it missing the reference to the worksheet or something?

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Passing name of shape to custom function


    So the error comes from the codeline calling this function …

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

    Re: Passing name of shape to custom function

    Guessing that the #Value error is because you are trying the use a UDF (UserDefinedFunction). And are using the function in a cell rather than code.

    cell formula, change name of shape to suit,
    =get_box_state("Rectangle 1")

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

  6. #6
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Passing name of shape to custom function

    Andy

    Bang on. Looks like it was the type for the name that was causing me the issue. Live and learn. Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How do I go about passing a custom class object from Excel to Word?
    By AnthonyGFS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2018, 07:40 AM
  2. [SOLVED] Passing a range to a sub from a shape (rectangle) on the worksheet
    By wazimu13 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2013, 01:01 PM
  3. [SOLVED] Passing combobox value to custom class
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 07-05-2012, 05:49 AM
  4. Passing combobox value to custom class
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-04-2012, 06:13 AM
  5. Passing Custom Class Variables through Functions
    By Xiazer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2006, 12:34 PM
  6. Passing Variables through Custom Dialog Boxes
    By Xiazer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-16-2006, 05:40 PM
  7. Passing an array as argument for custom Function
    By in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-07-2005, 01:06 PM

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