![]() |
Type mismatched in Listbox
I created a user form with a list box. I use the
following codes to fill the list sub main() Dim Mon_List As ListBox ' LstB_Months is the name of the Listbox on the form ' *** Get a "Run-time error 13. Type Mismatch" in the ' Set Mon_List statement below. - Why ??? Set Mon_List = UF_Generate_Report.LstB_Months Call Fill_Mon_List(UF_Generate_Report.LstB_Months) end sub ' A simple test routine sub Fill_Mon_List(MonList as ListBox) MonList.AddItem "Jan" MonList.AddItem "Mar" MonList.AddItem "May" end sub I'm getting "Run-time error 13. Type mismatch" error when I try to run this code. Can someone please tell me what I did wrong here ? Thanks in advance |
Type mismatched in Listbox
change
Dim Mon_List As ListBox to Dim Mon_List As MSForms.ListBox Excel has its own listbox object, but that object doesn't equal an msforms listbox. Also change this: sub Fill_Mon_List(MonList as ListBox) to sub Fill_Mon_List(MonList as MSForms.ListBox) -- Regards, Tom Ogilvy "Wellie" wrote in message ... I created a user form with a list box. I use the following codes to fill the list sub main() Dim Mon_List As ListBox ' LstB_Months is the name of the Listbox on the form ' *** Get a "Run-time error 13. Type Mismatch" in the ' Set Mon_List statement below. - Why ??? Set Mon_List = UF_Generate_Report.LstB_Months Call Fill_Mon_List(UF_Generate_Report.LstB_Months) end sub ' A simple test routine sub Fill_Mon_List(MonList as ListBox) MonList.AddItem "Jan" MonList.AddItem "Mar" MonList.AddItem "May" end sub I'm getting "Run-time error 13. Type mismatch" error when I try to run this code. Can someone please tell me what I did wrong here ? Thanks in advance |
All times are GMT +1. The time now is 03:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com