I have following code in VBA
to evaluate a variable lngPNumber
to send the "correct" value to a WorksheetFunction.vLookup
function:
Dim lngPNumber As Variant
lngPNumber = ActiveSheet.Cells(objInitialCell.Row, INT_ACCP_COL_PNUMBER).Value
If IsNumeric(lngPNumber) = False Or CDbl(lngPNumber) <> Round(CDbl(lngPNumber)) Then
lngPNumber = CStr(ActiveSheet.Cells(objInitialCell.Row, INT_ACCP_COL_PNUMBER).Text)
End If
lngPNumber
can be:
- an integer value (f.i. 4111)
- a float value (41.111111)
- or just a string value (normally "xxxx" but can also be filled with strings like "asdasd", "dasdsadasd", etc...)
In the last both cases, I want to send the Cell Text and not the Cell Value where lngPNumber
is obtained.
However, I get a Type Missmatch error if the value is a string like in the last example in the list. Any help?