+ Reply to Thread
Results 1 to 4 of 4

Define a public variable

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Define a public variable

    Hi ALl

    I want to define a public variable and i am using the following code but it gives me Compile error Invalid outside procedure.

    option explicit
    public ABC1 AS VARIABLE
    ABC1="FALSE"
    Any help would be much appreciated.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Define a public variable

    ABC1 = "FALSE"

    should be either part of sub or function. The top party is for declaring variables only

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Define a public variable

    You can not also use the word "Variable" as it is reserved word

    Public ABC1 As Long

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Define a public variable

    If you want to set the contents of the variable outside of procedures perhaps you really need to use a Const.

    Public Const ABC1 = "FALSE"
    This would make it available throughout your project but the contents would be read-only.

    Perhaps you should explain why you think you need a public variable.
    Cheers
    Andy
    www.andypope.info

+ 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. Public variable losing value
    By Ned Gallagher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2012, 11:25 PM
  2. Public Variable value
    By nfpaccounting in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2011, 02:34 PM
  3. ReDim Public Variable
    By mpeplow in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2007, 04:22 PM
  4. Public Variable
    By Digitborn.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2007, 03:54 PM
  5. [SOLVED] Public variable
    By Jack in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-18-2006, 05: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