vba user form initiate

CelineT

New Member
Joined
Mar 10, 2016
Messages
17
Hi all,

I have several user forms and i'm trying to fill in a listbox with items upon opening with the following code:

Code:
Private Sub Frm_Offer_Initialize()
    
   Dim Client As Range
   Dim i As Integer
   
   'Fill listbox with possible clients
    For Each Client In Range("T_Active[Name]")
        With Me.LstB_Clients
            .AddItem
            .List(i, 0) = Client.Value
            .List(i, 1) = Client.Offset(0, -1).Value
            i = i + 1
        End With
    Next Client
End Sub

T_Active is a table and exists with 2 columns:
- ID
- Name

This code worked perfectly for another form I used to show the suppliers, which works fine.

When I try to run this one, it gives me an empty listbox

Anyone an idea where I need to look?

Thanks
Céline
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi,
you renamed UserForm_Initialize event which most likely, is reason why you code does not work as intended

Change it back to it's original name

Rich (BB code):
Private Sub UserForm_Initialize()
    Dim Client As Range
   Dim i As Integer
   
   'Fill listbox with possible clients
    For Each Client In Range("T_Active[Name]")
        With Me.LstB_Clients
            .AddItem
            .List(i, 0) = Client.Value
            .List(i, 1) = Client.Offset(0, -1).Value
            i = i + 1
        End With
    Next Client
End Sub


Dave
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,709
Members
449,331
Latest member
smckenzie2016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top