passing argument problem ??

R

ricksimm

Using the following code:

Sub StartPPTOptions()
Call BuildListbox(PPTOptions.Name, _
PPTOptions.ClientPPTListbox.Name, _
"ClientMain1")
End Sub

Sub BuildListbox(lbForm, lbName, lbSource)
Dim AllCells As Range, Cell As Range
Dim NoDupes As New Collection
Dim Item

lbForm.lbName.Clear

Set AllCells = Range(lbSource)
On Error Resume Next
For Each Cell In AllCells
NoDupes.Add Cell.Value, CStr(Cell.Value)
Next Cell
On Error GoTo 0
For Each Item In NoDupes
lbForm.lbName.AddItem Item
Next Item
End Sub

I am trying to use one sub to build quite a few listboxes by passing
the needed arguments. When it hits the lbform.lbname.Clear I get an
"Object required" error. Thanks.
 
V

Vasant Nanavati

Sorry, but what exactly are you trying to accomplish? And where do you build
the ListBox? Not sure what:

lbForm.lbName.Clear

is supposed to accomplish. It appears that lbForm and lbName are strings
(even though you have not declared data types).
 

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