Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2017, 04:08 PM
eduzs eduzs is offline Populate listbox Windows 10 Populate listbox Office 2010 32bit
Expert
Populate listbox
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default Populate listbox

How programmatically populate a single column listbox?


Thanks
__________________
Backup your original file before doing any modification.
Reply With Quote
  #2  
Old 07-17-2017, 09:14 PM
gmayor's Avatar
gmayor gmayor is offline Populate listbox Windows 10 Populate listbox Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Is this a userform list box? With what do you want to populate it?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-18-2017, 02:57 AM
eduzs eduzs is offline Populate listbox Windows 10 Populate listbox Office 2010 32bit
Expert
Populate listbox
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

Yes a userform VBA listbox. Thanks
__________________
Backup your original file before doing any modification.
Reply With Quote
  #4  
Old 07-18-2017, 03:25 AM
gmayor's Avatar
gmayor gmayor is offline Populate listbox Windows 10 Populate listbox Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

So what do you want to populate it with?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 07-18-2017, 05:28 PM
eduzs eduzs is offline Populate listbox Windows 10 Populate listbox Office 2010 32bit
Expert
Populate listbox
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

Thanks, I found that:

To populate a two column listbox:

With UserForm.LB1
.ColumnCount = 2
.ColumnWidths = "6;6"
.AddItem "1"
.List(0, 0) = "Name1"
.List(0, 1) = "E-mail1"
.AddItem "2"
.List(1, 0) = "Name2"
.List(1, 1) = "E-mail2"
.ListIndex = 1 ' Sets the default value
End With

To retrieve: First Column: UserForm.LB1.Column(0, .LB1.ListIndex) Second column: UserForm.LB1.Column(1, .LB1.ListIndex)

To populate a single column listbox:

With UserForm.LB1
.AddItem "Name1"
.AddItem "Name2"
.ListIndex = 1
End with

To retrieve: UserForm.LB1.List(.LB1.ListIndex)
__________________
Backup your original file before doing any modification.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate listbox Excel ListBox koreggan Excel 1 04-23-2016 11:44 PM
Populate listbox ListBox with multiple columns Kaatje Word VBA 2 02-27-2016 09:37 AM
This is a Userform LIstbox queston: A variable does not set to the value of a listbox CatMan Excel Programming 14 08-18-2014 08:14 PM
Populate listbox This is a Userform LIstbox queston: A variable does not set to the value of a listbox CatMan Excel 1 08-08-2014 09:41 AM
as the return value of another column, using Listbox? marreco Excel Programming 1 03-27-2012 12:48 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft