Results 1 to 7 of 7

Global variable declared in Userform. Variable value is not sticking

Threaded View

  1. #1
    Forum Contributor timtim89's Avatar
    Join Date
    01-05-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    141

    Global variable declared in Userform. Variable value is not sticking

    Hey,

    Im in big need of getting this one solved, so hope someone can help me.

    As is easier seen in the attachment, I set my variable myName to be the Combobox1.Value

    I want this value to stick with the variable, so that when I activate Sheet2, myName still equals whatever I was set to in the userform. This is not the case though, since variable value is empty when I activate another sheet. Guess it has something to do with my declaration of the variable, but cant figure it out. Please help Thanks in advance!!

    Public myName As String
    
    Private Sub CommandButton1_Click()
    myName = ComboBox1.Value
    MsgBox "nyName now equals " & myName & vbNewLine & vbNewLine & "Try activate Sheet2 now"
    
    Worksheets(1).Range("a1").Value = myName
    
    Unload Me
    
    End Sub
    Attached Files Attached Files

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