+ Reply to Thread
Results 1 to 8 of 8

Type mismatch problem

  1. #1
    Registered User
    Join Date
    02-04-2024
    Location
    Riga, Latvia
    MS-Off Ver
    2013
    Posts
    4

    Type mismatch problem

    Hello guys,

    I'm just start studying and I have an exercise to do in VBA, so I'm a newbie in that
    I have faced a problem, that the operation can't be made cause of problem "Type mismatch", screenshot is added to this topic.
    Basically, I need to calculate wage after taxes, but probably because of the one result in formula with dot (.) in stead of comma (,) I can't get the result.
    I already tried to surf the internet, but probably I'm finding it in the wrong way.

    What I need to do to get this formula alive?
    Thank you in advance!

    Private Sub apr1_Click()
    socnn = brutal / 100 * 10.5
    socnd = brutal / 100 * 23.59
    urvn = "0,36"
    If combo.Visible = False Then
    iin = brutal / 100 * 23 - socnn / 100 * 20
    ElseIf brutal >= 1667 Then
    iin = ((1667 - apsum - neapl - socnn) / 100 * 20) + ((brutal - 1667) / 100 * 23)
    ElseIf (brutal - apsum - neapl) > 0 < 1667 Then
    iin = "(brutal - apsum - neapl - socnn) / 100 * 20"
    Else
    iin = 0
    End If
    neto = brutal - socnn - iin
    End Sub
    problem.pngBDAT_MD1_- Copy.xlsmBDAT_MD1_- Copy.xlsmproblem.png
    Last edited by zoox; 02-05-2024 at 04:20 PM.

  2. #2
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    411

    Re: Type mismatch problem

    Hello @zoox.
    Maybe, I'm not sure. Try:
    Please Login or Register  to view this content.
    For a more detailed understanding of your problem, please make a small example file and attach it to your starting post. And what are your operating system regional settings, "," or "." (delimiter)?

    Hi from Ukraine!
    Last edited by MikeVol; 02-04-2024 at 05:46 PM. Reason: Update
    NOTE: As the original poster/owner, only you can mark your thread as SOLVED (Thread Tools above Post #1).
    You can say "Thanks" in your thread to everyone who offered to help you.
    You can also reward them by clicking * "Add Reputation" under their username on the left.
    With Regards, MikeVol.

  3. #3
    Registered User
    Join Date
    02-04-2024
    Location
    Riga, Latvia
    MS-Off Ver
    2013
    Posts
    4

    Arrow Re: Type mismatch problem

    Hey MikeVol,

    Many thanks for you fast reply, but unfortunately the Dim features didn't helped me
    I added the copy of my xlsm file to my original post, maybe the problem is in the whole code or smthng, I have no idea, I'm already checked a lot of topics regarding this, but didn't found a solution ((

    Thank you in advance!

    btw I was in Odessa in 2008
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    536

    Re: Type mismatch problem

    I'm not seeing an error in the Copy.xlsm workbook uploaded in post #3 so am not sure what is the cause.

    Just by way of information, a "Type mismatch" error means that the value of some variable calculated by the code isn't matching the 'required' type. For example, if the code is expecting a variable value to be an integer value but the variable is actually a decimal value or a string value, that can throw up a "Type mismatch" error. Excel VBA tries to handle this type of thing by- for example- converting an apparent string to a numeric variable but sometimes it doesn't always succeed/ can't use the current value of the variable.

    I used a value of 700 in the 'brutal' text box (this object typically returns a string ["700" instead of 700] but your code converts it to a double so it's not clear to me what is causing the problem. It could be some 'internationalisation' issue as Mike suggested- maybe using a decimal point instead of a comma or vice versa (so 725.50 instead of 725,50, for example) is at the root of the problem but it was all OK on my laptop whichever value I used so long as the entry in the first textbox (brutal) is typed in as a genuine number rather than a string.
    Excel 365 user. To unblock a downloaded macro-enabled workbook, go to your "Downloads" folder > right click on the workbook name > click 'Properties' > check the 'Unblock' checkbox. You can now open the workbook.

  5. #5
    Registered User
    Join Date
    02-04-2024
    Location
    Riga, Latvia
    MS-Off Ver
    2013
    Posts
    4

    Re: Type mismatch problem

    Thanks to you MikeVol and deadlyduck for the help and your time!

  6. #6
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    411

    Re: Type mismatch problem

    del
    duplicate post, Sorry.
    Last edited by MikeVol; 02-08-2024 at 08:49 PM.

  7. #7
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    411

    Re: Type mismatch problem

    Good day @zoox. How did you solve your problem? Thank you for the reputation point! Peace and Health!

  8. #8
    Registered User
    Join Date
    02-04-2024
    Location
    Riga, Latvia
    MS-Off Ver
    2013
    Posts
    4

    Re: Type mismatch problem

    Hey Mike, basically, that was a regional windows settings problem :D

+ 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. Type mismatch problem
    By shelim481 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2020, 12:58 PM
  2. Type mismatch problem
    By terrypin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2019, 08:50 AM
  3. [SOLVED] type mismatch problem
    By mira255 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2012, 06:56 AM
  4. type mismatch problem
    By hotmalepiyush in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-02-2008, 08:50 AM
  5. Type mismatch problem
    By bernie1961 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2008, 01:20 PM
  6. Type mismatch problem
    By Dan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-31-2006, 12:00 PM
  7. [SOLVED] Type Mismatch Problem
    By Damien McBain in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2005, 12:06 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