• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

RUNTIME ERROR AT THE EXECUTION OF THE FILE.

DAGUET

Member
Dear VBA experts, I can't understand why I get this bloody message error when I select a country from the drop down list control of my userform.

I checked again and again and cant see where this could come from. Any idea ? Help welcome!!

best
 

Attachments

  • VBA XL - Tran Kevin - Loza Vincent - Lepeu Alexandre.xlsm
    51.7 KB · Views: 3
I tested your Combobox for Country, and got no error.

Please specify what error message you get and what line is highlighted when you go to debug mode.
 
I tested your Combobox for Country, and got no error.

Please specify what error message you get and what line is highlighted when you go to debug mode.
this one (see attached). Could it be linked to incompatibility US/European format I mean "." vs ","?
 

Attachments

  • error type.docx
    34.7 KB · Views: 3
... "." vs ","?

Possible...

Test if value returned is numeric...

If immediate window prints "False" then you know RF.Value/CTR value is returning text and not number.
Code:
Private Sub Country_Change()

    If Country.Value <> "" Then
    With Me
    .RF = Application.WorksheetFunction.VLookup(Me.Country, Range("L3:N46"), 2, 1)
    .CTR = Application.WorksheetFunction.VLookup(Me.Country, Range("L3:N46"), 3, 1)
    End With
    End If
    If RF.Value <> "" Then
    Debug.Print IsNumeric(RF.Value)
    RF.Value = RF.Value * 100
    Else
        RF.Value = 0
    End If
    If CTR.Value <> "" Then
    Debug.Print IsNumeric(CTR.Value)
        CTR.Value = CTR.Value * 100
    Else
        CTR.Value = 0
    End If
End Sub

If that's the case try nesting RF & CTR values in CDbl().
Ex.
Code:
RF.Value = CDbl(RF.Value) * 100
 
I just tried it and still got the same message (see the bug's report attached)
 

Attachments

  • bug.docx
    23.6 KB · Views: 3
What does your immediate window show? False or True?

Debug.Print is just to check if it's returning numeric or text. It won't alter your value in any way. Use CDbl() and see if it works. If not, you may need to replace "." with ",".
 
What does your immediate window show? False or True?

Debug.Print is just to check if it's returning numeric or text. It won't alter your value in any way. Use CDbl() and see if it works. If not, you may need to replace "." with ",".

it says False.

CDbl does not do it anyhow... I'll change dots for comas

Best Regards and Many Thanks
 
Back
Top