+ Reply to Thread
Results 1 to 3 of 3

Run-time error ‘13’: Type mismatch on Userform textbox if empty

  1. #1
    Forum Contributor
    Join Date
    01-08-2017
    Location
    Salt Lake City, Ut.
    MS-Off Ver
    2019 and 365
    Posts
    135

    Question Run-time error ‘13’: Type mismatch on Userform textbox if empty

    Userform Textboxes.jpg Error on Userform.jpg

    I have created a exel userform that performs calculations for banking account that is working pretty well, but if the entry for entry your bank account balance is deleted and your either hit enter or tab it crashes. (See attached file for :Userform Textboxes”.
    I have placed the following code in the Account Balance box that the user enters and it does work well when the user enters data in TextBox329. Textbox 328 is the Month end balance box.
    Private Sub TextBox329_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox330.Value = Format$(TextBox328.Value - TextBox329.Value, "0.00")End If
    EndSub
    TextBox330 is the box labeled Difference. I have tried the code TextBox code In many different locations, such as change, etc. The problem I am having is that if the box is empty, or if an entry has been deleted and the user hits enter or tab, it crashes and shows the error “Run-time error ‘13’: Type mismatch and if I click on Debug it takes me to the line above and shown in the attached file “Error on Userform”.
    The other text boxes are being loaded in a macro sing the follow code:
    UserForm4.TextBox328.Text = Worksheets(Sheetname).Range("O4").Value
    Where it is pulling data from an excel sheet where numbered values are stored. I have tried many different methods of trying to handle this error but have been unsuccessful. Any suggestions would be greatly appreciated.

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Run-time error ‘13’: Type mismatch on Userform textbox if empty

    You should convert strings to numbers before calculate
    Please Login or Register  to view this content.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Run-time error ‘13’: Type mismatch on Userform textbox if empty

    Perhaps:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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. [SOLVED] Getting run-time error 13 'type mismatch'
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2016, 09:10 PM
  2. Run-time error '13': Type mismatch
    By Janbi in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 02-09-2016, 12:53 PM
  3. Type mismatch error in userform
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-11-2016, 09:29 PM
  4. Run-time error 13 - Type Mismatch
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2012, 06:10 AM
  5. [SOLVED] Please help with Run-Time error 13 Type Mismatch
    By alec66317 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2012, 08:29 AM
  6. Run-Time error 13: type Mismatch Help!
    By Fellhouse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2011, 04:58 PM
  7. Passing Userform Listbox to sub causes type-mismatch error
    By Kleev in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2005, 04:05 PM

Tags for this Thread

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