Filling Lists with Workbook_Open

G

Guest

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.
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top