+ Reply to Thread
Results 1 to 7 of 7

User Defined Function Not Working Without Quotations

  1. #1
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    285

    User Defined Function Not Working Without Quotations

    Hi guys, I was wondering if one of you kind fellows could lend me a hand?

    I have created a function to simplify the calculation of a user specified column, however it looks first at a specified cell to find the specific worksheet to calculate, for example;

    =CalcStk(F6,G)

    This is telling it to look at F6 first to find out which worksheet to look at (column F contains sheet names), then calculate the total sum of everything in column G.

    The code I have works, it returns the correct figure. However, it does not work unless I input the function as;

    =CalcStk("F6","G")

    While this works, it is useless when it comes to another macro copying and pasting the formulas, as nothing inside the quotations changes as Excel sees it as text.

    Here is the code I have;
    Please Login or Register  to view this content.
    I know this is gonna be something stupid that i've missed, but i've been kicking myself all day trying to get it right.

    Any help is greatly appreciated, many thanks!

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

    Re: User Defined Function Not Working Without Quotations

    Try:

    Please Login or Register  to view this content.
    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...

  3. #3
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    285

    Re: User Defined Function Not Working Without Quotations

    Thanks Olly, Unfortunately this does not work, just returns the same old #VALUE error

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: User Defined Function Not Working Without Quotations

    What exactly do you have in column F?
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    285

    Re: User Defined Function Not Working Without Quotations

    Column F is just a list of sheet names, its looking at the specified cell for the sheet name, then using that information to set the range;

    Please Login or Register  to view this content.
    "page" reffers to the first variable, in this case "F6", then i'm asking it to use the value of the cell as the sheet name when setting the range.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: User Defined Function Not Working Without Quotations

    Declare page as string and change the code from Worksheets(Range(page).Value) to Worksheets(page).

    Also, change the way you set myrange so that acel can be either the column number or letter.
    Please Login or Register  to view this content.
    You could now use this,
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or this to call the function.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    285

    Re: User Defined Function Not Working Without Quotations

    May I kiss you sir? If that's too much I'll just hit the rep button.

    This works perfectly!

    Thank you so much!

+ 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. [SOLVED] User defined function returns an error on a standard function used in it.
    By pb48 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-23-2013, 01:35 PM
  2. Working with double quotations
    By tmellway in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-21-2012, 04:27 PM
  3. user defined fuction not recognized / not working
    By ztodd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2009, 03:09 PM
  4. vlookup path not working in UDF (User Defined Function)
    By miagovino in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2007, 01:16 PM
  5. Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 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