Skip to main content
10-Marble
January 26, 2026
Solved

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

  • January 26, 2026
  • 1 reply
  • 371 views

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

Best answer by Werner_E

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

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
January 26, 2026

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
10-Marble
January 26, 2026

Thank you very much!