View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Type Mismatch Error Populating Label


Make the Style property of the combobox fmDropDownList
iso fmDropDownCombo.

This prevents entering non-existing text.


as is:
during typing in the combo box the change event is fired..
with every character you type.. the vlookup is executed on partial text.

if the vlookup cannot find the item it returns a variant of type Error
which cannot be assigned to the Caption.
Wrap the Vlookup in cStr() to prevent the runtime error.


Small example:
Sub foo()
Dim v, s$
'Put an error in the variant
v = [=na()]
'Put it in a string w/o error
s = CStr([=na()])
'This will give err 13, Type Mismatch
s = [=na()]

End Sub








--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


ssjody wrote :

Rookie Here! This Code gives me a Type Mismatch Error if I try and
Type any Value in my Combo Box but if I Pick a choice from the Drop
Down it works fine. What am I doing wrong?

Jody

Private Sub cboCmPrimaryModel_Change()
Dim wo As Range
Set wo = Worksheets("PrimaryToOrionMakeCode").Range("A1:B3" )
If Me.cboCmPrimaryModel.Value "" Then
Label4.Caption = Application.VLookup(cboCmPrimaryModel.Value, wo, 2,
False)
End If
End Sub