ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   passing argument problem ?? (https://www.excelbanter.com/excel-programming/331645-passing-argument-problem.html)

ricksimm[_2_]

passing argument problem ??
 

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.


--
ricksimm
------------------------------------------------------------------------
ricksimm's Profile: http://www.excelforum.com/member.php...o&userid=21892
View this thread: http://www.excelforum.com/showthread...hreadid=378708


Vasant Nanavati

passing argument problem ??
 
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).

--

Vasant




All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com