+ Reply to Thread
Results 1 to 2 of 2

Declaring Global Constant

  1. #1
    Forum Contributor
    Join Date
    08-20-2012
    Location
    Walsall,England
    MS-Off Ver
    Excel 2007
    Posts
    125

    Declaring Global Constant

    Hi,

    I'm having trouble declaring a global constant. Here is the code line which is written at the top of a module (.row is highlighted when it errors):

    Public Const PupilCount As Long = Sheet9.Range("A65536").End(xlUp).Row

    Also, when is a global constant initialised? When the workbook is opened?

    Cheers

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Declaring Global Constant

    You can't have a constant that's the result of a variable by its definition.

    It has to be fixed, so in your scenario you'd Dim it rather than Const it. It would only be a constant if it's a fixed number so:

    Public Const PupilCount As Long = 10

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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