Populate 2 Column List box from Named Range

RLJ

Active Member
Joined
Mar 15, 2011
Messages
417
Office Version
  1. 365
Platform
  1. Windows
Hello, I have a UserForm1 with a ListBox1. I need it to display the 2 columns from the Named Range "Test_Range" when the userfom is loaded. Thank you for your help.

Calculator.xlsm
LM
22Current Year1/1/2024
2360 Days from YE3/1/2024
2490 Days from YE4/1/2024
25120 Days from YE5/1/2024
26150 Days from YE6/1/2024
27180 Days from YE7/1/2024
Date Calculator
Cell Formulas
RangeFormula
M22M22=DATE(YEAR(Abstract_Date),1,1)
M23M23=DATE(YEAR(Current_Year),MONTH(Current_Year)+2,DAY(Current_Year))
M24M24=DATE(YEAR(Current_Year),MONTH(Current_Year)+3,DAY(Current_Year))
M25M25=DATE(YEAR(Current_Year),MONTH(Current_Year)+4,DAY(Current_Year))
M26M26=DATE(YEAR(Current_Year),MONTH(Current_Year)+5,DAY(Current_Year))
M27M27=DATE(YEAR(Current_Year),MONTH(Current_Year)+6,DAY(Current_Year))
Named Ranges
NameRefers ToCells
Abstract_Date=Dashboard!$B$2M22
Current_Year='Date Calculator'!$M$22M23:M27


VBA Code:
Private Sub UserForm_Initialize()
    ListBox1.Clear
    ListBox1.ColumnCount = 2
    ListBox1.AddItem "Test_Range"

End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
One way would be to use the RowSource property...

VBA Code:
ListBox1.RowSource = "Test_Range"

Another way would be to use the List property...

VBA Code:
ListBox1.List = ThisWorkbook.Worksheets("Date Calculator").Range("Test_Range").Value

Hope this helps!
 
Upvote 0
One way would be to use the RowSource property...

VBA Code:
ListBox1.RowSource = "Test_Range"

Another way would be to use the List property...

VBA Code:
ListBox1.List = ThisWorkbook.Worksheets("Date Calculator").Range("Test_Range").Value

Hope this helps!
Thank you
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,089
Latest member
ikke

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