Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Type Mismatch Error Populating Label

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Type Mismatch Error Populating Label

Where is Me.cboCmPrimaryModel DIM'ed?
--
Gary''s Student


"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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Type Mismatch Error Populating Label

Thanks Gary. I still can't figure it out. Can you show me how to fix it?

  #4   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Type Mismatch Error - Help Please Launchnet Excel Worksheet Functions 5 July 20th 07 04:35 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
type mismatch error Monique Excel Programming 3 July 21st 05 09:19 AM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 08:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"