Drag your userform into a new workbook. Probably best to comment or store &
remove all code in the form module.
In a normal module -
change name of UserForm1 to that of your form
Sub CombosToListboxes()
Dim fm As UserForm 'Object
Dim i As Long
Dim ctr As Control, ctrLB As Control
Dim tp As Single
Set fm = ThisWorkbook.VBProject.VBComponents("UserForm1").Designer
tp = fm.InsideHeight
For Each ctr In fm.Controls
If TypeName(ctr) = "ComboBox" Then
i = i + 1
Set ctrLB = fm.Controls.Add("Forms.ListBox.1")
With ctr
Cells(i, 1) = ctr.Name
Cells(i, 2) = ctr.TabIndex
Cells(i, 3) = ctrLB.Name
ctrLB.Left = .Left
ctrLB.Top = .Top
ctrLB.Width = .Width
ctrLB.Height = .Height
' copy any other properties here
.Move 0, tp ' put combobox below the visible form
End With
End If
Next
End Sub
' manually make the form taller and delete all the comboboxes
' (not sure how to delete controls as 'designer', hence this two step
approach)
Sub renameListBoxes()
Dim fm As UserForm
Dim i As Long
Dim ctr As Control
Set fm = ThisWorkbook.VBProject.VBComponents("UserForm1").Designer
For Each ctr In fm.Controls
If TypeName(ctr) = "ListBox" Then
i = i + 1
ctr.Name = Cells(i, 1)
End If
Next
End Sub
Export the form from the original the original workbook. Drag the new form
back and if necessary replace the code. Hold your breath and test!
Regards,
Peter T