+ Reply to Thread
Results 1 to 4 of 4

How to keep the same Public for different functions in a single module?

  1. #1
    Registered User
    Join Date
    02-08-2023
    Location
    Germany
    MS-Off Ver
    365
    Posts
    80

    How to keep the same Public for different functions in a single module?

    I have different functions that are on different cells but they have this Clr variable.
    If I run my macro, only my function CountNum1 will go.

    I tried adding "Public clr As Boolean" before the next function, but I get an error message.

    Unless I don't need to and it works all the same with "Public clr As Boolean" only once at the top?

    public.png
    Last edited by Soraka; 04-01-2023 at 11:21 AM.

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

    Arrow Re: How to keep the same Public for different functions in a single module?


    So according to the explicit message why didn't you just obviously delete this duplicate codeline ?!

  3. #3
    Registered User
    Join Date
    02-08-2023
    Location
    Germany
    MS-Off Ver
    365
    Posts
    80

    Re: How to keep the same Public for different functions in a single module?

    Quote Originally Posted by Marc L View Post

    So according to the explicit message why didn't you just obviously delete this duplicate codeline ?!
    "Public clr As Boolean" is not present in the module outside at the very top.
    I only tried to copy paste before Function CountNum2

    The reason is:
    I have a button with a macro to clear different cells that have those CountNum#
    Although, when I press it, only the first cell is cleared, so I figured it was because of the Public statement missing before the other functions.

    Here is my Clear button:
    Sub Clear()
    Application.ScreenUpdating = False
    Range("S24") = 0
    Range("U28") = 0
    Range("V28") = 0
    clr = True
    Range("A68:J77,V4:V19,W4:W19").ClearContents Here only A68 is cleared, the rest is not
    Range("A68").Formula = "=CountNum1(S24)"
    Range("A69").Formula = "=CountNum2(S24)"
    The rest of the code is just replacements of the functions to be removed, exactly like A68 and A69
    I only thought the reason why the cells after A68 not being cleared is because of the Public statement, but maybe not. Hence why I typed it, yet removed after it as it was not working.
    Last edited by Soraka; 04-01-2023 at 11:46 AM.

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

    Arrow Re: How to keep the same Public for different functions in a single module?


    Two different issues : one from the duplicate codeline and the other maybe 'cause of a bad design or logic, whatever …
    As clr has nothing to do with the ClearContents codeline !

    For more help so obviously rather than a guessing challenge - as most helpers do not play this game ! - attach at least your workbook.

+ 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] Public and Private scope in a module
    By tfurnivall in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2023, 04:54 PM
  2. [SOLVED] Passing public variables to sub in another module
    By maboho93 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-22-2018, 09:58 AM
  3. [SOLVED] Issue Accessing Public Multidimensional Array in Another Module
    By Sprucie in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-24-2016, 06:05 AM
  4. Trigger a public function in a module from a datepicker change
    By whitwoo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-24-2014, 09:13 AM
  5. Help with Public module =Timestamp()
    By lpratt in forum Excel General
    Replies: 2
    Last Post: 01-27-2011, 02:44 AM
  6. Macro in single button when used public functions
    By shekar goud in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2009, 11:06 AM
  7. [SOLVED] How to add a public subroutine to a class module
    By keithb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2005, 04:40 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