Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:12:11+00:00 2026-06-12T13:12:11+00:00

I have a situation where a defined table structure changes based on a control

  • 0

I have a situation where a defined table structure changes based on a control type (for my instance it is a Product Brand). In that Table there are two column/fiels that will need to be used to populate two Data-Validation cells on the same worksheet. These cells are above the Table, and “ideally” would be used to filter the Table’s information based on the data populating the Data-Validation cells.

Data-Validation List Method Logic:

  Dim str As String
  str = Join(UniqueValues(ws,srcrng), ",")
  Dim val As Excel.Validation
  Set val = range(destrng).Validation
  val.Delete
  val.Add xlValidateList, xlValidAlertStop, xlBetween, str
  • ws: Worksheet where @srcrng is located
  • srcrng: Range to extract the Unique values from
  • destrng: Range where the Data-Validation will be attached to. This will be controlled to be only a single cell and error out if has more than 1 row and 1 column.

The Above method is encapsulated in a method which is passed two parameters Table1[Column1] and DataValidationCell1 in VBA.

Just to stave off any questions, here is the method UniqueValues logic:

Function UniqueValues(ws As Worksheet, col As String) As Variant

   Dim rng As range: Set rng = ws.range(col)
   Dim dict As New Scripting.Dictionary

   If Not (rng Is Nothing) Then
      Dim cell As range, val As String

      For Each cell In rng.Cells
         val = CStr(cell.Value)
         If InStr(1, val, ",") Then
            val = Replace(val, ",", Chr(130))  <-- Handles the fact i have commas in the field
         End If

         If Not dict.Exists(val) Then
            dict.Add val, val
         End If

      Next cell
   End If

   'Return value as Variant Array
   UniqueValues = dict.Items
End Function

Questions:

  1. How do i account for Data-Validation changes?
  2. Can i use Data-Validation to Filter a Table?
  3. Since Pivot-Table is not a plausible option, due to the nature of the information, and if Data-Validation Filtering is not functionally possible, what alternative do i have?

On #3, i would like to not place a Drop-Down List, if at all possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:12:13+00:00Added an answer on June 12, 2026 at 1:12 pm

    Data-Validation is a way to restrict what kind of data can be entered in a cell (or a range of cells) http://office.microsoft.com/en-us/excel-help/apply-data-validation-to-cells-HP010072600.aspx

    So your question is not specific to data validation. Your question seems to be about filtering a table based on the values entered in two cells at the top of that table (that happen to have data validation applied to them). Am I correct? If so: you are going to need to run a macro everytime those data validation cells are changed. You could make this automatic with Sub Worksheet_Change(ByVal Target As Range) or you could have an “update filters” button that would be slightly less “cool”. Either way, you simply need to link in a macro with those two cells and have them update the filter on the table based on the values of those two cells.

    Here is an example of a macro that would do something like I described:

    Sub Worksheet_Change(ByVal Target As Range) 
    
        ActiveSheet.AutoFilterMode = False 
        Range("A3:H20").AutoFilter 
        Range("A3:H20").AutoFilter Field:=2, Criteria1:=Range("A1").Text 
    
    End Sub 
    

    This is from: http://www.ozgrid.com/forum/showthread.php?t=85547

    Hope this helps. Good Luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this situation I have two models, Comment and Score. The relationship is defined
The Situation I have a table in a DB that contains job types, basically
The situation is that I have a table that models an entity. This entity
I have situation, where running a query that filters by an indexed column in
We have situation where say we have four engineers that are working on software
I have a table containing hierarchical data. There are currently ~8 levels in this
My situation may be a bit abnormal, but I have foreign keys defined in
I have a situation where a certain linq query that runs against a multi-million
I have a fairly unique situation trying to map a single table to multiple
My situation is this: We have a superclass, MyAbstractEntity @Entity @Table(name = MyTable) @Inheritance(strategy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.