SOLVED

Type missmatch

Occasional Contributor

Hi ive run into trouble in a weired situation of type mismatch error

There are two computers installed the same version and build and both 64 bit

When the vba code runs in the first it doesnt return any error but the same cone runs in thd other and returns type mismatch error what could ther root cause of thus problem be?

9 Replies

@Excelworksprograms 

Can you click Debug in the error message and find out which line causes the problem?

I just found that a cells value is like this
Wsabc.cells(1,2).value=cdbl(txtabc) in which txtabc is on a user form the code runs by clicking a command button on the form
The problem is this code runs on my computer and some other but it gets to a type mismatch on another computer with same version and build of excel
best response confirmed by Excelworksprograms (Occasional Contributor)
Solution

@Excelworksprograms 

See if it works if you use

 

Wsabc.Cells(1,2).Value = Val(txtabc.Text)

 

If not: do the users where it fails use a different decimal separator than you (point vs comma)?

Oh thanks yes i think that user uses / instesd fo comma.does the val function gives a numerical value ?

@Excelworksprograms Val always returns a numeric value, but it may not be what you wanted. You may have to use

 

Wsabc.Cells(1,2).Value = Val(Replace(txtabc.Text, ",", "."))

The users r different another person may use some other character instead of comma or /

@Excelworksprograms 

A / as decimal separator? I've never seen that. Or are they entering a date?

Oh i should check the code again when i get home the textbox doesnt get filled by typing it is calculated by another code which is for sure a double value then i want to save that in a cell on sheet

@Excelworksprograms 

See how it works, it's best to test with various settings.