0

I have a listbox added to a userform. When I set a property, add an item, etc. via code, nothing appears in the listbox. I don't get an error, the listbox just remains blank. Here's a snippet. I reviewed the listbox properties and Enabled and Visible are true, Locked is false.

Private Sub Refresh_Click()
ListBox1.Clear
Dim wb As Workbook
UserForm1.ListBox1.BackColor = RGB(5, 5, 5) 'threw this in for testing; box not changed
For Each wb In Workbooks
   MsgBox wb.Name
   ListBox1.AddItem wb.Name 
   'this is what I'm trying to accomplish; 
   'wb.Name shows in the MsgBox but not in the listbox
Next wb
End Sub
1
  • this code is inside the userform? change userform1.BackColor to me.BackColor Commented Mar 23, 2016 at 18:38

1 Answer 1

2

The code has no errors and works, but i had to change the fore-color of the listbox in order to see the item

Sign up to request clarification or add additional context in comments.

6 Comments

What did you change the ForeColor property to?
simply to white, because this line UserForm1.ListBox1.BackColor = RGB(5, 5, 5) tured the Listbox into black (nearly)
I just can't get this to work. I deleted the listbox and added a new one and still no luck. Here's the current code:
Private Sub Refresh_Click() Dim wb As Workbook For Each wb In Workbooks ListBox1.AddItem wb.Name Next wb End Sub
sorry, i have no idea, i created a Userform1, perform the load ans show stuff and executed your code without any problems...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.