![]() Dim x As Long ' VBA will convert to integer 100 In general, VBA is very forgiving when you assign the wrong value type to a variable e.g. ' Declare a variable of type Date Dim ReportDate As Date ' Assigning a number causes a type mismatch error If we try to place a non-date in this variable we will get a VBA Type mismatch error ' Sub TypeMismatchDate() This time we have a variable ReportDate of type Date. ' Declare a variable of type long integer Dim total As Long ' Assigning a string will cause a type mismatch error If we try to place text in the variable we will get the VBA Type mismatch error(i.e. ![]() Imagine we have a variable called Total which is a Long integer. The error appears as “run-time error 13 – Type mismatch”.įor example, if you try to place text in a Long integer variable or you try to place text in a Date variable. ![]() 3 How to Locate the Type Mismatch ErrorĪ VBA Type Mismatch Error occurs when you try to assign a value between two different variable types.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |