Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Excel 2003 - Combobox.AddItem type mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mario - 22 Jan 2007 14:23 GMT
Hi there ,

I found the following code to add items to a combobox in a userform for
Excel 2002 , and works just fine in version 2002.

Private Sub UserForm_Initialize()
'   Executed before the form is shown
   Dim Row As Integer
   Set HelpSheet = ThisWorkbook.Sheets(HelpSheetName)
   TopicCount =
Application.WorksheetFunction.CountA(HelpSheet.Range("A:A"))
   For Row = 1 To TopicCount
       ComboBoxTopics.AddItem HelpSheet.Cells(Row, 1)
   Next Row
   ComboBoxTopics.ListIndex = 0
   CurrentTopic = 1
   UpdateForm
End Sub

Now I've transferred this code (+ all other codes) and the userform to Excel
2003 and it gives an error message when adding items to the combobox.

Error message =
Run-time error '-2147352571 (80020005)
                          Type mismatch

When debugging the code stops at
ComboBoxTopics.AddItem HelpSheet.Cells(Row, 1)

Anyone have an idea where the error comes from ?
Thanks for helping out.
Mario
Mario - 22 Jan 2007 14:31 GMT
Thanks , but I solved the problem

I've added a new variable StrCombItem
Use StrCombItem to store the value from ==> HelpSheet.Cells(Row, 1)
and changed the additem value
ComboBoxTopics.AddItem  StrCombItem

This works for me.
Mario

> Hi there ,
>
[quoted text clipped - 29 lines]
> Thanks for helping out.
> Mario
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.