cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Translate the entire conversation x

How do I remove empty rows from a drop-down menu?

DD_13910355
10-Marble

How do I remove empty rows from a drop-down menu?

How do I remove empty rows at the end of the second drop-down menu when selecting "steel" in the first drop-down menu?

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:DD_13910355)

You could use "ReDim" to redimension variable "Section".

Sub ComboBoxEvent_Start()

Material= Worksheet.GetValue("Material")		

If Material= "Cast Iron" Then 
   Dim Section(2)	
   Section(0) = "1"
   Section(1) = "2"
   Section(2) = "3"

ElseIf Material= "Steel" Then 
   ReDim Section(2)	
   Section(0) = "A"
   Section(1) = "B"
   Section(2) = "C"
Else
   ReDim Section(4)	
   Section(0) = "A1"
   Section(1) = "B2"
   Section(2) = "C3"
   Section(3) = "D3"
   Section(4) = "E3"
End If

ComboBox.List() = Section
End Sub

View solution in original post

4 REPLIES 4
Werner_E
25-Diamond I
(To:DD_13910355)

You could use "ReDim" to redimension variable "Section".

Sub ComboBoxEvent_Start()

Material= Worksheet.GetValue("Material")		

If Material= "Cast Iron" Then 
   Dim Section(2)	
   Section(0) = "1"
   Section(1) = "2"
   Section(2) = "3"

ElseIf Material= "Steel" Then 
   ReDim Section(2)	
   Section(0) = "A"
   Section(1) = "B"
   Section(2) = "C"
Else
   ReDim Section(4)	
   Section(0) = "A1"
   Section(1) = "B2"
   Section(2) = "C3"
   Section(3) = "D3"
   Section(4) = "E3"
End If

ComboBox.List() = Section
End Sub

Thank you very much!

Is it possible to implement the same solution so that the row names in the second menu are defined not in the menu code, but in an array on the MathCAD file, designated by a variable above the menu itself. This way, each row name is assigned a corresponding value, also defined in an array like the row names?

Werner_E
25-Diamond I
(To:DD_13910355)

That's sure possible to implement.

You might be interested in Richards collection of components here -> Extra Components and Controls - PTC Community
Especially the section "Dynamically filled list boxes" in the last third of the sheet.

I am not sure if it will be of use to you but I also attached an old quite elaborate file from Tom Gutman which may be of interest. It feeds the boxes from Excel files. i have not tested if his solution still works in MC14/15. Maybe its necessary to resave the Excel files in xlsx format?

 

 

 

Announcements

Top Tags