ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   ListBox, error 424 (https://www.excelbanter.com/excel-worksheet-functions/30564-listbox-error-424-a.html)

coldmejl

ListBox, error 424
 
Hi!

Iīm trying to add items to a list box, using the following code:


Code:


ListBox1.Clear

While Not recordsetSales.EOF
ListBox1.AddItem (recordsetSales.Fields("product"))
recordsetSales.MoveNext
Wend


The problem is that I get 'Error 424: Object required', and I canīt figure out why.

Any help appreciated! Thanks!

Edit: I want this code to be executed when the Excel document opens, and have therfore out it in ThisWorkbook under the sub Workbook_Open(). If I use the same code on a CommandButton_click it works. Do I have to specify in which sheet the listbox is situated or something?

coldmejl

Solved it! Thanks anyway!


All times are GMT +1. The time now is 12:40 AM.

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