【问题标题】:excel drop down grabbing info from another sheetexcel下拉从另一张表中获取信息
【发布时间】:2014-06-29 16:31:33
【问题描述】:

我正在尝试创建一个下拉列表,其中包含我的工作簿中其他工作表的名称。当我从下拉列表中选择其中一个名称时,我希望它从该表中获取所有人的姓名并使用下拉列表显示在表上。但我无法弄清楚。

【问题讨论】:

    标签: excel ms-office excel-2013


    【解决方案1】:

    使用此代码:

    Dim SheetSel As Boolean
    
    Sub InitCMB()
        ComboBox1.Clear
        For Each xx In Sheets
            ComboBox1.AddItem xx.Name
        Next
        SheetSel = True
    End Sub
    
    Private Sub ComboBox1_Change()
        If SheetSel = True Then
            e = ComboBox1.ListIndex + 1
            SheetSel = False
            ComboBox1.Clear
            ComboBox1.AddItem ".."
            For i = 1 To 9999
                If Sheets(e).Range("A" & i).Value = "" Then Exit For
                ComboBox1.AddItem Sheets(e).Range("A" & i).Value
            Next
        Else
            If ComboBox1.Value = ".." Then InitCMB
        End If
    
    End Sub
    

    您在组合中插入工作表的名称 (InitCMB)。
    如果您选择一张工作表,宏会将名称从 A1 加载到所选工作表的末尾。
    在列表顶部添加“..”,如 dir。当您选择“..”时,您将返回工作表列表。

    【讨论】:

      猜你喜欢
      • 2021-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-02
      • 2017-05-23
      • 2019-08-06
      • 2017-12-08
      • 1970-01-01
      相关资源
      最近更新 更多