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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,216,333
Messages
6,130,089
Members
449,557
Latest member
SarahGiles

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