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:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
can i check one thing. do you want the list in sheet3 to have gaps where the blanks are (ie a 1 to 1 mapping of your userform) or do you just want a list of populated comboboxes dumped into the sheet
 
Upvote 0
VBA Code:
Sub Update()
    ' update sheet3 with no blanks
    Dim Ctrl As MSforms.Control, CtrlCount As Long
    With Sheets("Sheet3")
        For Each Ctrl In UFProductionSheet.Controls
            If TypeName(Ctrl) = "ComboBox" Then
                If Ctrl.Value <> "" Then
                    CtrlCount = CtrlCount + 1
                    .Cells(CtrlCount, 55) = Ctrl.Value
                End If
            End If
        Next
    End With
End Sub
 
Upvote 0
can i check one thing. do you want the list in sheet3 to have gaps where the blanks are (ie a 1 to 1 mapping of your userform) or do you just want a list of populated comboboxes dumped into the sheet
Just a list of populated comboboxes in a single column.
 
Upvote 0
ok so the code i posted should be on the right track. let me know if it needs changes
 
Upvote 0
VBA Code:
Sub Update()
    ' update sheet3 with no blanks
    Dim Ctrl As MSforms.Control, CtrlCount As Long
    With Sheets("Sheet3")
        For Each Ctrl In UFProductionSheet.Controls
            If TypeName(Ctrl) = "ComboBox" Then
                If Ctrl.Value <> "" Then
                    CtrlCount = CtrlCount + 1
                    .Cells(CtrlCount, 55) = Ctrl.Value
                End If
            End If
        Next
    End With
End Sub
 
Upvote 0
I attempted the code you provided but still encounter the same issue. When I use F8 to step through the process, it just loops and loops.
One thing I notice that is different from my old workbook vs this new one that I am having the issue with is the following (not sure if this has anyting to do with it.)

On my old workbook, which has a similar form that performs the same functions as what I'm trying to accomplish with the new one, i populate each combobox list via named ranges witint the worksheet. The code for that was as follows:
UFProductionSheet.cbBEnhance1.List = Application.WorksheetFunction.Transpose(Range("BEnhance"))
When I use the code in the first post of this thread, it simply did as expected, which is put the value of each non blank combobox in a column without any blanks between them.

With this new sheet however, when I use f8 to step through the code, it actually goes trhough each line of code used to populate the comboboxes prior to actually before actually doing the loop to create the lost of combobox selections, only it never stops, it just keeps looping. The following code is what I have used to populate the combobox list in my new worksheet:
UFProductionSheet.ComboBox1.List = Sheet4.Range("A2", Range("A2").End(xlDown)).Value
Mind you, there are 475 comboboxes so this took me a great deal of time to accomplish, but I fear this is the cause of my issue somehow.
Is ther some sort of alteration besides creating 475 names ranges in the workbook itself that I can make that will maybe allow this process to actually complete? I'm raeally distraught over the fact that I may have to do this all over again.

I appreciate you efforts helping me. I wish I knew more, but I think I have tried to accomplish more than I should given my VBA knowlege.
Thanks again in advance!
 
Upvote 0
post the code that has the endless loop in it
 
Upvote 0
I'm hesitant to link the workbook here so you can see what I'm taking about because the code I've used is not at all in the format you mentioned earlier (indented). Plus I'm sure it could have been written better, but it's the best I could do with what I know this far. Consequently, the file size is a bit extreme (for a spreadsheet) But if it'll help, I'm willing.
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

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