+ Reply to Thread
Results 1 to 2 of 2

Public Variable value

  1. #1
    Registered User
    Join Date
    03-26-2011
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    10

    Public Variable value

    I have a single Module with 4 Subroutines. 2 of the Subs share a single variable.
    I am not sure why the variable is losing the value.

    Here is a example code:

    Public LastRow as Long (This is at the top of my module)

    Public Sub CreateLiab()
    Lastrow = 0
    some code
    Lastrow = lastrow+1
    more code
    CreateFile (Here I am calling a second sub that will share the variable
    End sub

    Public Sub CreateFile()
    Myvalue = LastRow (The Value of LastRow comes across as zero?
    code
    End sub.

    I was under the impression if the scope is public, I should be able to use the value of the variable Lastrow from the Sub CreateLiab() in my Sub CreateFile().


    Any assistance will be appreciated.

    Thanks

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Public Variable value

    Hi nfpaccounting, please use code tags around your code. If you do that someone here will be able to help. If you are unsure about code tags, please refer to the forum rules button located beside the log out button.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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