![]() |
Filling Lists with Workbook_Open
Hello guys,
I'm trying to fill various lists at the workbook_open event (at startup). This is what i have in the class named "Startup" Option Explicit Dim ws As Worksheet, rng As range, lst As ListObject Sub fillLists(rng) Set ws = Sheets("CODE") Set rng = ws.range(rng) Set lst = ws.ListObjects.Add(xlSrcRange, rng, , xlYes) End Sub And this is my code in the class "ThisWorkbook": Option Explicit Dim listRob As New Startup Private Sub Workbook_Open() listRob.fillLists ("A2:A8") End Sub The call to fillLists gives me the following error: "Error 1004". Application or Object-defined error What am i doing wrong here? Thanks in advance. |
Filling Lists with Workbook_Open
All looks a bit skewy.
What is listRob? If it is a listbox somewhere, perhaps the code should be Private Sub Workbook_Open() listRob.List = Sheets("CODE").Range("A2:A8") End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Memento" wrote in message ... Hello guys, I'm trying to fill various lists at the workbook_open event (at startup). This is what i have in the class named "Startup" Option Explicit Dim ws As Worksheet, rng As range, lst As ListObject Sub fillLists(rng) Set ws = Sheets("CODE") Set rng = ws.range(rng) Set lst = ws.ListObjects.Add(xlSrcRange, rng, , xlYes) End Sub And this is my code in the class "ThisWorkbook": Option Explicit Dim listRob As New Startup Private Sub Workbook_Open() listRob.fillLists ("A2:A8") End Sub The call to fillLists gives me the following error: "Error 1004". Application or Object-defined error What am i doing wrong here? Thanks in advance. |
All times are GMT +1. The time now is 11:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com