+ Reply to Thread
Results 1 to 3 of 3

Public Const Declaration of Workbooks, Worksheets, Ranges, etc.

  1. #1
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Public Const Declaration of Workbooks, Worksheets, Ranges, etc.

    I would like to use the same variables in a number of procedures. Can I not declare those as Public and Constant prior to my procedures?

    i.e.
    Please Login or Register  to view this content.
    I know that I can declare them here, but am trying to avoid (re)setting them over and over again within each procedure. Any help or guidance appreciated.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Public Const Declaration of Workbooks, Worksheets, Ranges, etc.

    Constants are just that -- they are assigned values based on expressions containing literals, other constants, and arithmetic operations -- that's it.

    You can declare them as public variables and then initialize their values in some Init routine.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: Public Const Declaration of Workbooks, Worksheets, Ranges, etc.

    If you declare them Public, outside of any module they should be fine. Just ensure that you aren't (re-)declaring them anywhere else.

+ 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. Trying to link a variable to a public const
    By ttd in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-27-2012, 11:44 AM
  2. Public Worksheet Declaration
    By wilro85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2009, 08:08 PM
  3. public const
    By jocke in forum Excel General
    Replies: 1
    Last Post: 12-06-2006, 01:17 AM
  4. public const availability?
    By lcoreyl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2006, 11:22 AM
  5. [SOLVED] Public declaration
    By Greg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2005, 07:06 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