List box value as table from tifferent columns

brendalpzm

Board Regular
Joined
Oct 3, 2022
Messages
59
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
Let's say I have a table like this, which is the data base

1680206929108.png


And I inserted a list box from ActiveX controls where I want to set a table but only with A B and D columns. How can I do this?

I'm not using user form
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Thanks for posting on the forum.

Just for information, the userform has an initiation or activation event, this event can load data into the listbox.
In a listbox of an Activex controls it is necessary for an event to occur, it can be when the workbook is opened, when a sheet is activated, etc. I am giving you an example, you must create a button to load the listbox, then you click on the button and the data will be loaded:

VBA Code:
Private Sub CommandButton1_Click()
  Dim i As Long
  With ListBox1
    .ColumnCount = 3
    .Clear
    For i = 1 To Range("A" & Rows.Count).End(3).Row
      .AddItem Range("A" & i).Value
      .List(.ListCount - 1, 1) = Range("B" & i).Value
      .List(.ListCount - 1, 2) = Range("D" & i).Value
    Next
  End With
End Sub

Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
 
Upvote 0
Thanks for posting on the forum.

Just for information, the userform has an initiation or activation event, this event can load data into the listbox.
In a listbox of an Activex controls it is necessary for an event to occur, it can be when the workbook is opened, when a sheet is activated, etc. I am giving you an example, you must create a button to load the listbox, then you click on the button and the data will be loaded:

VBA Code:
Private Sub CommandButton1_Click()
  Dim i As Long
  With ListBox1
    .ColumnCount = 3
    .Clear
    For i = 1 To Range("A" & Rows.Count).End(3).Row
      .AddItem Range("A" & i).Value
      .List(.ListCount - 1, 1) = Range("B" & i).Value
      .List(.ListCount - 1, 2) = Range("D" & i).Value
    Next
  End With
End Sub

Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
Thanks for your reply! I did what you wrote and it marks a run-time error '-2147467259 (80004005)' of unspecified error
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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