+ Reply to Thread
Results 1 to 10 of 10

A handy new personal discovery after decades of using VBA :)

  1. #1
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    A handy new personal discovery after decades of using VBA :)

    I'm not a beginner, though I surprise myself at my occasional talent at brain damaged/senile inability to see the obvious. Here's something that just hit me for whatever reason after decades of coding.

    If a Function fnFoo has As Range, then you can just go
    i = fnFoo.Row

    In all my lame thinking years I've gone
    set rng = fnFoo
    i = rng.Row

    I never connected that you could directly use properties of a return value that's a range. Doh!!

    Tell me if you know exceptions to using properties or methods directly against a function call.

    Perhaps it's just because I normally return numbers or strings, and TMK I'm unaware of any properties that apply to nonobjects, whereas properties are often the only reason you access a Object
    Chip, if you can read this, you're STILL making the world a better place with your immeasurably valuable gifts. Every week, you continue to help me (and untold numbers of others) tremendously. Practically no alternative outlets can match your effectiveness, even over the vast number of topics you demystify and empower usage of. You were, and still are, amazing.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,886

    Re: A handy new personal discovery after decades of using VBA :)

    The only issue I'd have with that is what if the function returned Nothing, not a valid range? That's one reason I pretty much always use a variable, plus you can inspect it in the Locals window.
    Rory

  3. #3
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: A handy new personal discovery after decades of using VBA :)

    Thanks for those thoughts. Both are strong points. Also, of course, if I were to call the function extra times because I didn't save the output, that would be something, though that seemed too obvious to bother to say.

    Moderator: I considered water cooler, but instead put this in the VBA forum because it better benefits readers by being there. It's a technical analysis. If it was moved to punish me for the wimpy, noninformative thread title, though, I'm on board with that

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: A handy new personal discovery after decades of using VBA :)

    Good evening Oppressed1

    I moved it to the Water Cooler, not because it would better benefit readers, or as a punishment for the "wimpy title" - your words, not mine.

    Whilst it would be perfectly at home in the VBA section, it's more of an interesting discussion point than a question. In the VBA section it would be all but lost within an hour or so; putting it in the Water Cooler will prolong the life of the discussion and probably be seen by more users, leaving the post closer to the top for longer, as threads tend to move slower here.

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  5. #5
    Valued Forum Contributor
    Join Date
    11-15-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    538

    Re: A handy new personal discovery after decades of using VBA :)

    Thanks for taking the time to clarify that. I'm not sure but I might be flattered by that explanation LOLz.

    Just for your amusement, as to how this was titled, to be a good user I spent real time and struggled to find something concise and gave up. My shortest try was
    "Can you directly use a property or method from a Function invocation, as opposed to saving the retval in an object variable and then using ITS property or method?"

    Thus arose the clickbaity title

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: A handy new personal discovery after decades of using VBA :)

    "Directly referring to properties of a function"
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: A handy new personal discovery after decades of using VBA :)

    But functions don't have properties in VBA

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

    Re: A handy new personal discovery after decades of using VBA :)

    Meaning ?

    Please Login or Register  to view this content.
    Last edited by snb; 02-05-2019 at 04:05 AM.



  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: A handy new personal discovery after decades of using VBA :)

    Meaning they’re not objects and your code doesn’t illustrate your point. You’re calling functions on the returned value, not the function itself

  10. #10
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: A handy new personal discovery after decades of using VBA :)

    So, where a function returns an object, you may refer to the object properties as if it were the function itself.

    It's still not a very snappy title..

+ 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. Hi, working with excel after decades away.
    By Piper101 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 06-15-2018, 11:17 AM
  2. Replies: 4
    Last Post: 07-18-2012, 08:54 PM
  3. Replies: 2
    Last Post: 07-10-2012, 03:56 PM
  4. Some Handy Personal Macros: Clear-Duplicates-Below-Selection
    By GeneralDisarray in forum Excel Tips
    Replies: 0
    Last Post: 07-10-2012, 02:20 PM
  5. Decades from year
    By cathey in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-23-2009, 01:04 PM
  6. Whites To Be A Minority in the U.S. in decades.
    By WhiteRaceUnited in forum Excel General
    Replies: 2
    Last Post: 04-14-2006, 03:35 PM
  7. [SOLVED] Great discovery?
    By David in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-12-2005, 04:06 AM

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