基于先前选择的Excel动态下拉菜单

时间:2019-02-04 09:54:55

标签: excel dynamic drop-down-menu

美好的一天,

我只能找到表格非常简单而数据最少的示例。我正坐在36个品牌上,并在下面的数据上整理了3 072个变体,我需要对其进行整理。

下面的A列到E列是我的数据的摘录,G列到I列是我需要进行的选择。进行解释。

  

Blockquote

Col G:应该是Col C中的值的下拉列表(这很容易,并且已经完成)

  

Blockquote

Col H:如果现在我在Col G中选择Abarth,我只希望在下拉菜单中显示500/695或124,我将在其中选择124

  

Blockquote

Col I:与Col H类似,现在下拉菜单中仅应显示Abarth 124相关项目

enter image description here

1 个答案:

答案 0 :(得分:0)

已解决!我编写了宏来解决以下问题:

Sub SelectModel()
'
' SelecModel Macro
'

'
    ActiveCell.Select

'   Save the active cell to use later
    Set myActiveCell = ActiveCell
    Set myActiveWorksheet = ActiveSheet
    Set myActiveWorkbook = ActiveWorkbook

    ActiveCell.Copy Destination:=Sheets("2018MMCodes").Range("AU1")

    Sheets("2018MMCodes").Select
    If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
        ActiveSheet.ShowAllData
    End If
    Columns("AV:AX").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Selections").Select
    Range("A1").Select
    ActiveSheet.Paste
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    ActiveSheet.Range("$A$1:$C$3257").RemoveDuplicates Columns:=2, Header:= _
        xlYes

    'Returns the user to the original sheet to enable just making a selection
    myActiveWorkbook.Activate
    myActiveWorksheet.Activate
    myActiveCell.Activate

End Sub
Sub SelectVariant()
'
' SelectVariant Macro
'

'
    ActiveCell.Select

'   Save the active cell to use later
    Set myActiveCell = ActiveCell
    Set myActiveWorksheet = ActiveSheet
    Set myActiveWorkbook = ActiveWorkbook

    Selection.Copy

    Sheets("2018MMCodes").Select
    Range("AU3").Select
    ActiveSheet.Paste
    Columns("AV:AX").Select
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Range("AV1:AX3257").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        Range("'2018MMCodes'!Criteria"), Unique:=False
    Selection.Copy
    Sheets("Selections").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    'Returns the user to the original sheet to enable just making a selection
    myActiveWorkbook.Activate
    myActiveWorksheet.Activate
    myActiveCell.Activate

End Sub