简体   繁体   中英

Populating a Table from Multiple Data Sets in Excel with Only Fields that Have Values

I want to create a table that populates from multiple tables, but only for the columns that have values.

For example:

User 1 from table 1 (T1: User 1) has:

  • 2 Apples
  • 1 Bananas
  • 0 Pears
  • Total Fruit: 3

User 2 from table 1 (T1: User 2) has:

  • 0 Apples
  • 0 Bananas
  • 2 Pears

  • Total Fruit: 2

User 1 from table 2 (T2: User 1) has:

  • 3 Apples
  • 1 Bananas
  • 1 Pears
  • Total Fruit: 5

This would populate the table with T1: User 1's data, then T1: User 2's data, then T2: User 1's data.

But if User 2 had a 0 total, the table would exclude User 2's data in the table and would populate the column with T2: User 1's data after T1: User 1's data.

例

I'm looking to dynamically merge multiple tables of data that excludes instances where the total is 0. As an additional wrinkle, this table should have no blank columns, so it lists each instance that has data one after the next.

I've been experimenting with extremely long nested IF statements, but I'm not sure if there's a more elegant approach to this scenario.

If you are starting from SQL tables, you can use SSIS to get only what you need. Please let us know what is your source.

There's no Excel function to do that simply.

Using Excel-VBA is the way to go. Learn by using tutorials. We won't do your work assignment for you.

Maybe a place to start:

How to search on worksheet by VBA Code?

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