+ Reply to Thread
Results 1 to 3 of 3

Userform not hiding once task is carried out

Hybrid View

  1. #1
    Registered User
    Join Date
    02-16-2013
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    24

    Userform not hiding once task is carried out

    I have a user form that's designed to come up when Excel opens, and the users name is not on the spreadsheet (i.e. it's the user's first time using the sheet).

    Everything is working well, save the functionality to close the spreadsheet after OK_Click action in the user form. I've tried changing using userform.hide in both when conditions are met in the OK_Click action, and after the DO LOOP in the sub that calls the userform... neither have worked. Any suggestions?

    Workbook open sub:
    Private Sub Workbook_Open()
    
    Sheets("Forecast").Select
    
    MsgBox "Forecasting Sheet" & vbCrLf & "Release 0.2"
    
    Do
    
    ByValue = Range("A4").Value
    
    If Len(ByValue) > 0 Then Exit Do
    
    ConNameForm.Show vbModal
        
    Loop
    
    End Sub
    Userform:
    '
    ' User form designed to allow entry of consultant code. At present,
    ' this will input the Consultant's name into Cell Range "A4" on
    ' the "Forecast" sheet. Over time the value will be concatenated with
    ' with NMP object variables to be input to library file
    '
    
    Sub ConNameForm()
    
    Dim ConFirstName As String
    Dim ConLastName As String
    Dim ConFullName As String
    
    End Sub
    
    Private Sub OK_Click()
    
    If Len(ConFirstName) > 0 Then
        If Len(ConLastName) > 0 Then
    
    ConFullName = ConFirstName & " " & ConLastName
    
    Range("A4").Value = ConFullName
    
        End If
    End If
    
    End Sub
    
    Private Sub ClearForm_Click()
    
    ConFirstName.Text = ""
    ConLastName.Text = ""
    
    End Sub
    
    Private Sub ConFirstName_Change()
    
    ConFirstName = ConFirstName.Text
    
    End Sub
    
    Private Sub ConLastName_Change()
    
    ConLastName = ConLastName.Text
    
    End Sub
    
    'Private Sub EnableSave()
    
    '    Set OK.Enabled = True
    '    Set ClearForm.Enabled = True
    
    'End Sub
    
    'Private Sub DisableSave()
    
    '    Set OK.Enabled = False
    '    Set ClearForm.Enabled = False
    Thanks in advance for any help you can lend. If you're familiar with selecting shape objects in a Range in Excel, I've posted another issue I've run into with this work book here.
    Attached Files Attached Files
    Last edited by dystopianprotagonist; 03-16-2013 at 06:35 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Userform not hiding once task is carried out

    Do you mean?

    Private Sub OK_Click()
    
    If Len(ConFirstName) > 0 Then
        If Len(ConLastName) > 0 Then
    
    ConFullName = ConFirstName & " " & ConLastName
    
    Range("A4").Value = ConFullName
    Unload Me
    
        End If
    End If
    
    End Sub
    Harry.

  3. #3
    Registered User
    Join Date
    02-16-2013
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Userform not hiding once task is carried out

    Yes, that would be ideal. When I used ConFullName.hide vbModal there I get a compile error that says Expected Function or Variable.

    UPDATE: After some google work, I found that you literally meant to use Unload Me and it worked. Thanks for your help!
    Last edited by dystopianprotagonist; 03-16-2013 at 06:34 PM.

+ 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