Consulting

Results 1 to 5 of 5

Thread: Problems Initiating a User Defined Function UDF - Using Application.caller.row

  1. #1
    VBAX Regular
    Joined
    Oct 2016
    Posts
    51
    Location

    Problems Initiating a User Defined Function UDF - Using Application.caller.row

    Hello Specialists
    I posted a previous question and received an answer that worked based on the attachment but I could not get it to work when it was downloaded. It uses an application.caller row setup to place the function as part of the worksheet. The question has been declared Solved.

    Of course, I believe that the issue is with me:
    1. am I initiating the UDF macro correctly ( I am going to the vba editor and pressing the run
    2. I have a cell in the spreadsheet selected to ensure that it is an active sheet
    3. the spreadsheet is the only spreadsheet that is open.

    The link to the previous question is below for
    "VBA Coding for Averageifs that needs to dynamically adjust over 8 quarters"

    http://www.vbaexpress.com/forum/show...ers&highlight=

    Any suggestions are so very much welcome.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    You aren't supposed to run the macro, because it's a function in a cell (cells B4 and B5 in Paul's sample file).
    All you need to do is allow the sheet to calculate.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular
    Joined
    Oct 2016
    Posts
    51
    Location
    Ah..the light comes on! Now I understand...and thank you.
    I have a further related question if I may...

    1. Can the macro be adapted and used in another workbook/worksheet? If so, how would you initiate the macro to get the formula properly in place? I have another averageifs spreadsheet that will need a similar treatment.

    I thank you for being here for we beginners.

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    It will already work in any worksheet within the workbook, but to use it in any workbook you could move it to a standard module in personal.xlsb, but then you'd have to enter the formula as:
    =PERSONAL.XLSB!Average8Quarters()

    Otherwise, have the function in a standard code module in any workbook that's going to use it.

    There is no 'initiating' to do.

    Bear in mind that if used on another sheet, that sheet should have similar rows 2 and 3, otherwise it will fail/give the wrong answer.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Regular
    Joined
    Oct 2016
    Posts
    51
    Location
    Terrific, p45cal. I am definitely going to try it in another workbook. And I think I have enough now to attempt to do it.
    Thank you for that.

Posting Permissions

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