+ Reply to Thread
Results 1 to 6 of 6

How to make VBA function “VBA only” and disable it as User defined function

  1. #1
    Forum Contributor
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    405

    Cool How to make VBA function “VBA only” and disable it as User defined function

    Hi guys,

    I have the same question as someone else see:
    https://stackoverflow.com/questions/...able-it-as-udf

    However in the link, they don't actually have an answer, the closest they have is a "return error if someone tries to use this.", which is not what i am looking for.

    I want to make a function that is available to other modules (public), but also does not show up as a function in the worksheet.

    (Maybe something to do with Class? Maybe not?)

    Thanks!
    Jimmy
    Thanks,

    JimmyWilliams

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: How to make VBA function “VBA only” and disable it as User defined function

    I depends on from where you want to use the funcion

    Insert this line at the top of the module containing the function:
    Option Private Module
    ... which hides the function (ie cannot be used as UDF)
    ... but function usable from other GENERAL modules

    Example - try this
    (The sub returns the value of selected cell in a message box, and the function is not visible from the worksheet)

    place in MODULE1
    Please Login or Register  to view this content.
    place in MODULE2
    Please Login or Register  to view this content.
    When the file containing the above code is open, TestIt can be run from any workbook
    Last edited by kev_; 02-18-2018 at 06:31 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Contributor
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    405

    Re: How to make VBA function “VBA only” and disable it as User defined function

    I have never heard of a "General" module before, can you please elaborate?

    My notes on Option Private Module say:
    "Variables are public only within the project they reside."

    How do i know what is a project and what is not a project?
    How can i group workbooks into projects? (I think that's how it might work?)

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: How to make VBA function “VBA only” and disable it as User defined function

    I have never heard of a "General" module before, can you please elaborate?
    I use the word "General". You may be familiar with the term "Standard". Anyway - they are the same thing

    Read this excellent guide from Chip Pearson - it explains the difference between module types.
    Last edited by kev_; 02-18-2018 at 10:31 AM.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to make VBA function “VBA only” and disable it as User defined function

    Quote Originally Posted by JimmyWilliams View Post
    How do i know what is a project and what is not a project?
    How can i group workbooks into projects? (I think that's how it might work?)
    1 workbook = 1 project.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: How to make VBA function “VBA only” and disable it as User defined function

    I want to make a function that is available to other modules (public), but also does not show up as a function in the worksheet.
    Have you tested the code in post#02?
    - it does what you asked
    Last edited by kev_; 02-18-2018 at 04:59 AM.

+ 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 to make my own [user-defined function] for min value except 0
    By slastanrado in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-24-2017, 11:22 AM
  2. [SOLVED] Usage of standard functions into custom function (or user defined function)
    By tusharb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2016, 12:43 AM
  3. COUNTIF/COUNTIFS function + nested user-defined function
    By shamjamali in forum Excel General
    Replies: 1
    Last Post: 05-12-2015, 09:12 PM
  4. [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
  5. [SOLVED] User Defined Function - How to make available to any Excel Sheet - Add-Ins - Update msg
    By vba_madness in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2013, 09:46 AM
  6. [SOLVED] 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
  7. [SOLVED] Need to open the Function Arguments window from VBA for a user defined function.
    By korrin.anderson@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2006, 10:55 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