+ Reply to Thread
Results 1 to 4 of 4

Userform Textbox Exit Event to Run Application

Hybrid View

  1. #1
    Registered User
    Join Date
    08-04-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Userform Textbox Exit Event to Run Application

    I have this code that should update textPERC everytime i exit another Textbox...

    Sub TextMOTid_exit(ByVal Cancel As MSForms.ReturnBoolean)
    Application.Run = percupdate()
    End Sub
    
    Sub percupdate()
     'UserFORM Percentage
    
        With textPERC
            'Set the text of the label.
                 textPERC.Caption = Format(expression:=Sheet1.Range("A3"), Format:="0.00%")
            'Automatically size the label control.
                 .AutoSize = True
                 .WordWrap = False
            'Set the font used by the Label control.
                 .Font.Name = "Tahoma"
        End With
    End Sub
    However on exit i get the following error...
    'Compile Error:
    Expected Function or Variable'

    Probably something simple!!
    Last edited by baisty182; 11-29-2010 at 12:31 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Userform Textbox Exit Event to Run Application

    Sub TextMOTid_exit(ByVal Cancel As MSForms.ReturnBoolean)
       percupdate
    End Sub
    should do.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Userform Textbox Exit Event to Run Application

    Quote Originally Posted by baisty182 View Post
    I have this code that should update textPERC everytime i exit another Textbox...

    Sub TextMOTid_exit(ByVal Cancel As MSForms.ReturnBoolean)
    Application.Run = percupdate()
    End Sub
    
    Sub percupdate()
     'UserFORM Percentage
    
        With textPERC
            'Set the text of the label.
                 textPERC.Caption = Format(expression:=Sheet1.Range("A3"), Format:="0.00%")
            'Automatically size the label control.
                 .AutoSize = True
                 .WordWrap = False
            'Set the font used by the Label control.
                 .Font.Name = "Tahoma"
        End With
    End Sub
    However on exit i get the following error...
    'Compile Error:
    Expected Function or Variable'

    Probably something simple!!
    Application.Run is not a value to be assigned, hence no =, and the parameter is a quotes enclosed string containing the procedure name.

    But as pointed out, Application.Run is superfluous.

  4. #4
    Registered User
    Join Date
    08-04-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: Userform Textbox Exit Event to Run Application

    Perfect thanks!!

+ 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