Dynamic Ranges Populate Comboboxes

EXCEL-LENCY

Board Regular
Joined
Feb 9, 2010
Messages
75
Hello,

I have a combobox "VIEW_ITEM_DETAIL_CMB_BX" on the sheet Output that has VBA Code Name "OUTPUT_PAGE". I want to populate that combobox with the dynamic range I've defined as "DYN_COST_DATABASE_ITEMS". This code works when I am populating comboboxed on a userform, but when the combobox is on a sheet, it doesn't work. Help would be greatly appreciated!!

Dim Otpt As Worksheet
Dim Cmb_Bx_Value As Range
Set Otpt = OUTPUT_PAGE

For Each Cmb_Bx_Value In Otpt.Range("DYN_COST_DATABASE_ITEMS")
With Otpt.VIEW_ITEM_DETAIL_CMB_BX
.AddItem Cmb_Bx_Value.Value
.List(.ListCount - 1, 1) = Cmb_Bx_Value.Offset(0, 1).Value
End With
Next Cmb_Bx_Value

Thanks!!
Jason
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

EXCEL-LENCY

Board Regular
Joined
Feb 9, 2010
Messages
75
Can anyone help? I need to populate a combobox on a worksheet with a dynamic range that is contained in the same workbook but a different worksheet.
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi, This works for me :-
Code:
Dim Otpt As Worksheet
Dim Cmb_Bx_Value As Range
Set Otpt = Sheets("OUTPUT_PAGE") ' See Here !!!!!
For Each Cmb_Bx_Value In Otpt.Range("DYN_COST_DATABASE_ITEMS")
With VIEW_ITEM_DETAIL_CMB_BX
.AddItem Cmb_Bx_Value.Value
.List(.ListCount - 1, 1) = Cmb_Bx_Value.Offset(0, 1).Value
End With
Next Cmb_Bx_Value
Regards Mick
 

EXCEL-LENCY

Board Regular
Joined
Feb 9, 2010
Messages
75
Thanks Mick. Still isn't working. The Code Name is OUTPUT_PAGE but the Sheet Name is OUTPUT... either way should work in that regard. Not sure why it isn't working...
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi, I've altered the cpode slightly to Take account of the sheet name and add reference to ColumnsCount = 2
This was run from another sheet and worked OK.
Code:
[COLOR="Navy"]Sub[/COLOR] MG07Aug41
[COLOR="Navy"]Dim[/COLOR] Otpt [COLOR="Navy"]As[/COLOR] Worksheet
[COLOR="Navy"]Dim[/COLOR] Cmb_Bx_Value [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Otpt = Sheets("OUTPUT")
VIEW_ITEM_DETAIL_CMB_BX.ColumnCount = 2
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Cmb_Bx_Value [COLOR="Navy"]In[/COLOR] Otpt.Range("DYN_COST_DATABASE_ITEMS")
[COLOR="Navy"]With[/COLOR] VIEW_ITEM_DETAIL_CMB_BX
.AddItem Cmb_Bx_Value.Value
.List(.ListCount - 1, 1) = Cmb_Bx_Value.Offset(0, 1).Value
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]Next[/COLOR] Cmb_Bx_Value
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,773
Messages
5,513,349
Members
408,948
Latest member
robertjohn18

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top