COMBOBOX VALUES

robertmwaring2

Board Regular
Joined
Mar 8, 2019
Messages
132
Office Version
  1. 365
Platform
  1. Windows
I have a userform that contains a mutlipage with 15 pages. All total, there are 475 comboboxes between the pages on this one form (yes i realize this is alot).
I am attempting to compile a list of all the combox values that are not left blank into a single column on a sheet within the workbook the form is apart of (Sheet3.Range("BC2:BC??"). I have used the following code previoulsy, but for whatever reason it now just loops endlessly IF any comboboxes on page 1 of the multipage are left blank.

VBA Code:
Dim Ctrl As Object
   For Each Ctrl In UFProductionSheet.Controls
      If TypeName(Ctrl) = "ComboBox" Then
         If Ctrl.Value <> "" Then
            Sheet3.Range("BC" & Rows.Count).End(xlUp).Offset(1).Value = Ctrl.Value
         End If
      End If
   Next

I really don't relish the idea of having to allocate a specific cell in the worksheet for each combobox to hold the value of the box on a change event, as I mentioned - there are 475 of them. The code above has worked flawlessly in the past, but I am in the process of creating a revised workbook that would allow for users to update more information and be less restrictive. Somewhere along the line, one of the changes I've made has caused this to stop functioning as it once did. I use the above code as a module that is called on a button click. Can anyone help me?
 
Last edited by a moderator:
Essentially, yes. But there are some menu items that require additional information. For example, one buffet may get a choice of meat.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
so do a small step first and build up. is there a list of all the possible types of service (as in the items on the far right listbox in the pic i sent. i will show you how i got the list box working
 
Upvote 0
I suppose that would be the actual captions of each of the mutlipage pages. Or, if it's easier, all the remaining worksheets in the workbook if you eliminate the master info, info, welcome, and production sheets. The goal though (as with the multipage pages) would be for that list to correspond to each worksheet name and would update if the sheet name changed.
 
Upvote 0
yes it needs to be dynamic. so for now lets use the sheet names. heres you first task. i am working in the userform_initialize section. dump all the combobox code except combobox1. then the first bit of new code will be right at the start. it is the listbox code. you can put 3 litboxes as i have done un the userform. leave names as default
 
Upvote 0
So, just to be clear, I'm erasing everything in the userform initialize except the code related to combobox 1?
 
Upvote 0
yeh thats fine. do a save as before you start on this LOL
 
Upvote 0
so to insert the names into the listbox, you do the following:

VBA Code:
Private Sub UserForm_Initialize()
    'populate listboxes 1 - 3
    With ListBox1
        .AddItem "Breakfast"
        .AddItem "Breaktime Snack"

you can change what i have in the "" ""
and then add the rest of the items from your sheet names. last line is
VBA Code:
End With
so there are 2 new things i have used here. firstly when you need to reference something over and over as you have had to do, i have used a With / end with section. this means that i dont have to type "ListBox1" over and over. the hard way is to type
VBA Code:
ListBox1.additem "...."


and the other new thing is i used an indent to mark for myself that i am using a with block
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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