Avatar of jmcclosk
jmcclosk
 asked on

Changing data displayed on a worksheet using drop-down box and second worksheet

I have two worksheets in a workbook.  The first worksheet is just a classic table of data for every single pallet location in a warehouse (upwards of 20,000 rows).  For each location, there are eight fields of data:

1. Cell# on worksheet 2 that corresponds to this location
2. Location
3. Area
4. Warea
5. Wzone
6. Capacity
7. Velocity
8. Travel Seq

The second worksheet is a visual layout of the warehouse with each cell being a unique location relating to one of the rows in the first worksheet.

In Cell A1 of the second worksheet, I have a drop-down list where the end user can select any one of the seven fields (not including Cell#).  When they make a choice, I want the second (visual) worksheet to update all 20,000 cells to display the piece of data associated with the users selection.

For example, if the user selected "Location", I want all 20,000 cells to display the unique location# associated with that cell#.  Then, if they select "Capacity", I want all 20,000 cells to update and show the pallet capacity for the location associated with that cell#.

I know how to make the worksheet update when the end user makes a selection.  But, I don't know how to write the formula for each cell on spreadsheet 2.

Would I use some kind of VLOOKUP formula?  If so, what syntax do I use to have it look up the curernt cell# as the lookup value?  And, how do I tell it how many columns to go to the right to get which piece of data depending on what the end user wants to see?
Microsoft Excel

Avatar of undefined
Last Comment
jmcclosk

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
rspahitz

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Rory Archibald

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jmcclosk

ASKER
I believe either of these solutions would work.  Mine was more complicated than these.  I was able to set up a way, with VBA, that when the option was selected by the end user for which data they wanted to see, cell $FZ$1 is updated with the column number for the corresponding data on Worksheet 1.  I then used the following formula in all of the cells on Worksheet 2 to automatically update the data to match that column:

VLOOKUP((ADDRESS(ROW(),COLUMN(),4)),AllData,$FZ$1,FALSE)

ADDRESS(ROW(),COLUMN(),4) returns the cell# of the current cell
AllData is the range I set up on Worksheet 1 where the data resides
$FZ$1 is the cell that holds the column number of the data the end user wants to see
FALSE tells the statement I want an exact match

I used the following VBA code to force the Worksheet to update immediately upon end user selection:

Private Sub Worksheet_Change(ByVal Target As Range)
   
    If Not Intersect(Range("A1"), Target) Is Nothing Then
           
        If Range("A1", "A1").Value = "LOCATION" Then
       
            Range("FZ1", "FZ1").Value = 2
            Exit Sub
        End If
       
        If Range("A1", "A1").Value = "AREA" Then
       
            Range("FZ1", "FZ1").Value = 3
            Exit Sub
        End If
       
        If Range("A1", "A1").Value = "WAREA" Then
       
            Range("FZ1", "FZ1").Value = 4
            Exit Sub
        End If
           
        If Range("A1", "A1").Value = "WZONE" Then
       
            Range("FZ1", "FZ1").Value = 5
            Exit Sub
        End If
       
        If Range("A1", "A1").Value = "CAPACITY" Then
       
            Range("FZ1", "FZ1").Value = 6
            Exit Sub
        End If
       
        If Range("A1", "A1").Value = "VELOCITY" Then
       
            Range("FZ1", "FZ1").Value = 7
            Exit Sub
        End If
       
        If Range("A1", "A1").Value = "TRAVEL SEQ" Then
       
            Range("FZ1", "FZ1").Value = 8
            Exit Sub
        End If

    End If
   
End Sub
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck