简体   繁体   中英

Update table with another table based on cell value

After searching, I understand I can copy data into a table one at a time using VLOOKUP. However, is it possible to replace an entire table with another if a cell contains a certain value?

For example,

I have a table1. I want to replace table1 with table2 if cell a1="table2"

The reason is I will have many tables and depending on what I put in a cell, A1, I want table 1 to be what ever table I choose. I also want it to be easily updated when I add even more tables.

Edit for more information:
I have one table lets call it table1. Another table, Table2, with columns Name and Values. Also I plan on having more tables, so Table3 with columns Name and Values. I have a cell somewhere on the page, or another page. If I write Table2 in this cell. I would like the entire Table1 to be replaced by table2. Ultimately copying the data in.

I have tried structured tables, but it only copies from the same row. If I put it in another row, i get null basically. Vlookup, I think requires me to have a formula for each row of the table. I might be using this formula wrong.

Without knowing more, one solution is INDIRECT() .

Example workbook sheets:

  • Table1
  • Table2
  • Table3
    • Assume all Table# tabs have the same cell range.

Make a new tab Input :

     [A]             [B]   
[1]  User Input
[2]  Table #         1
[3]  
[4]  Reference       ="'Table"&B2&"'!"

The formula in B4 evaluates to 'Table1'! . Note that the sheet reference includes the apostophes in case the sheet name has spaces.

Make a new tab Summary Table :

     [A]
[1]  =INDIRECT(Inputs!$B$4&ADDRESS(ROW(),COLUMN()))

This formula displays the value in the specified sheet name (from Inputs!B4 ) and the current row and column (so when this formula is entered in A1 , it will display the value of Table1!A1 ). Then fill this formula across the rows and columns necessary to display the table specified in the Input tab.

Note of course that you could combine the Input and Summary Table tabs, but you would need to adjust the ROW() and/or COLUMN() formulas. This is also the case if your source tables do not begin in cell A1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM