Link to home
Start Free TrialLog in
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?
ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmcclosk
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