根据命名范围内的列过滤验证列表

发布于 2024-11-09 10:19:09 字数 334 浏览 0 评论 0原文

我正在寻找一种基于多列命名范围在 Excel 中过滤列表验证的方法。

我在一张纸上有一个产品版本列表,包含在具有以下列的命名范围中:名称、类型、状态。在另一张纸上,我希望用户能够从仅包含“名称”的验证列表中进行选择。 这里的问题 3741060 介绍了如何使验证列表仅包含“名称”列。但是,我还需要进行过滤,以便用户无法选择状态为“已完成”的版本。 [状态列只允许“计划”、“已分配”或“已完成”。]

理想情况下,我还想根据另一个验证动态仅显示“计划”或“已分配”版本 - 但我想如果我可以获得完全过滤列表我应该能够完成剩下的事情。 顺便说一句 - 我被迫为此使用 Excel 2003,尽管我不认为这会是一个主要因素。

I am looking for a way to filter a list validation in Excel based on a multi-column named range.

I have a list of product releases on one sheet, contained in a named range that has the columns: Name, Type, Status. On another sheet, I want the user to be able to select from a validation list containing 'Name' only.
Question 3741060 here covers how to make the validation list only contain the 'Name' column. However I also need to filter so that the user cannot select a release with the status 'Completed'. [The status column only allows 'Planned', 'Allocated' or 'Completed'.]

Ideally I would also like to dynamically show only 'Planned' OR 'Allocated' releases based on yet another validation - but I think if I can get the list filtered at all I should be able to do the rest.
BTW - I am forced to use Excel 2003 for this, although I don't believe would be a major factor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独﹏钓一江月 2024-11-16 10:19:10

我在隐藏工作表中使用

  • 额外范围 LOV(值列表),用用户可以选择的当前条件填充该工作表(在我的情况下,当他/她填充工作表时,这会因行而异)
  • 中的所有单元格主表根据此范围 LOV 进行验证
  • 在每个光标从可能选择的原始范围移动后,Selection_Change() 触发器会加载 LOV

这就是我重新生成 LOV 的方式(本质上,用户已经在另一个单元格中选择了国家/地区代码)在字符串 CtyCd 中传递到这里,现在该表准备提供一系列可能的选择,仅针对这个国家称为 GINI 的东西......所以可能类似于您的需求)

Sub LoadL2LOV(CtyCd As String, LOVL2 As Range)
'
' CtyCd is a selection criterium for the original list in range GINI
' LOVL2 is the target range containing the current list of values
' all cells in sheet have a validation against range LOV defined
'
Dim GINI As Range, Idx As Long, Jdx As Long, LName As Name, Adr As String

    ' clear current PoP_L2
    Set LName = ActiveWorkbook.Names(LOVL2.Name.Name)
    Set GINI = Worksheets("GINI Availability").Range("GINI")
    LOVL2.ClearContents

    ' set new LOV for PoP_L2
    If CtyCd <> "" Then
        Idx = 2
        Jdx = 1

        ' find 1st occurence of CtyCd in GINI
        Do While GINI(Idx, 4) <> CtyCd And GINI(Idx, 4) <> ""
            Idx = Idx + 1
        Loop

        ' GINI is sorted, just read until the end of selected CtyCd
        Do While GINI(Idx, 4) = CtyCd
            LOVL2(Jdx, 1) = GINI(Idx, 1) & "-" & GINI(Idx, 2) & "-" & GINI(Idx, 3)
            Idx = Idx + 1
            Jdx = Jdx + 1
        Loop
    End If

    ' redefine LOV name to contain all current valid choices
    LOVL2.CurrentRegion.Name = LOVL2.Name.Name
End Sub

在您的情况下,因为数据似乎或多或少静态,您可以将所有有效选择从 [Prod_Release] 复制到 Sheet_Activate 或任何适当的激活触发器处的 LOV。

希望这有帮助......祝你好运 MikeD

I use

  • an extra range LOV (for List of Values) in a hidden sheet that I fill with the current criteria the user can choose from (in my case this varies from line to line as he/she fills the sheet)
  • all cells in the main sheet are validated against this range LOV
  • a Selection_Change() trigger loads the LOV after each cursor move from the original range of possible choices

This is how I re-generate my LOV (in essence the user has already selected a country code in another cell passed here in string CtyCd, and the sheet now is prepered to offer a selection of possible choices of something called GINI for only this country ... so maybe similar to your demand)

Sub LoadL2LOV(CtyCd As String, LOVL2 As Range)
'
' CtyCd is a selection criterium for the original list in range GINI
' LOVL2 is the target range containing the current list of values
' all cells in sheet have a validation against range LOV defined
'
Dim GINI As Range, Idx As Long, Jdx As Long, LName As Name, Adr As String

    ' clear current PoP_L2
    Set LName = ActiveWorkbook.Names(LOVL2.Name.Name)
    Set GINI = Worksheets("GINI Availability").Range("GINI")
    LOVL2.ClearContents

    ' set new LOV for PoP_L2
    If CtyCd <> "" Then
        Idx = 2
        Jdx = 1

        ' find 1st occurence of CtyCd in GINI
        Do While GINI(Idx, 4) <> CtyCd And GINI(Idx, 4) <> ""
            Idx = Idx + 1
        Loop

        ' GINI is sorted, just read until the end of selected CtyCd
        Do While GINI(Idx, 4) = CtyCd
            LOVL2(Jdx, 1) = GINI(Idx, 1) & "-" & GINI(Idx, 2) & "-" & GINI(Idx, 3)
            Idx = Idx + 1
            Jdx = Jdx + 1
        Loop
    End If

    ' redefine LOV name to contain all current valid choices
    LOVL2.CurrentRegion.Name = LOVL2.Name.Name
End Sub

In your case, as the data seems to be more or less static, you can copy all valid selections from [Prod_Release] to LOV at Sheet_Activate or any appropriate activation trigger.

Hope this helps .... good luck MikeD

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文