Using Solver to Assign Items to Buckets

Share

Facebook
Twitter
LinkedIn

In April 2011, Mdsuhair asked a question at the Chandoo.org Forums

What formula can I use to divide a group of numbers into 2 groups so that the Sum of each of the 2 groups is as equal as possible?

This is a candidate for Solver.

This post will walk us through the solution to the problem using Solver. It uses Solver and screen shots from Excel 2007.

All versions of Excel have solver available. Users should note that the screen shots may not match your version although the functionality will, some of the functions appear in different locations in different versions of Solver.

What and Where Is Solver

What is Solver

Solver is an Excel add-in that can solve problems by enabling a Target cell to achieve some goal.

This goal may be to minimse, maximise, or achieve some target value.

It solves the problem by adjusting a number of input cells according to a set of criteria or constraints which are defined by the user.

Where is Solver

Solver is an Excel add-in supplied with Excel, but not enabled by default.

To enable solver

File, Excel Options, Add-ins, Manage Excel Add-ins, Select the Solver Add-in checkbox

Solver will now appear as a New Tab on the Data, Analysis Tab

Solver Example

This post is based around a worked example Solver Example File, the file is compatible with all versions of Excel.

Defining the Problem

Mdsuhair had a series of 8 Items each which had a value:

 

He wants to know which items should be combined so that the sum of the values of the items is nearly equal.

To do this we need to assign each item into a Bucket. Namely Bucket A and Bucket B.

We will put values of 1 into a Bucket for each Item to show that it is assigned to that Bucket and a value of 0 to show that the bucket is empty (In/Out) Value.

We can start by adding a Total Column, which counts items in Buckets A + Bucket B for each Item, It then totals the totals.

We also know that we need to work out the Value of each Item in each Bucket

We do this by multiplying the Items Value by the Buckets (In/Out) value

Finally we need to add up the values in each Bucket and work out the difference between them

Mdsuhair’s original problem was to minimise the difference between the sum of the values in the 2 buckets.

Now we can place values of 1 in the buckets manually and Excel will show us the value of each Bucket and the Difference between them in Cell G11.

I have applied some conditional formatting to show when a cell has a value > 0.

The problem is that there are 28 or 256 combinations of answers, and to test them all manually at 1 every 5 seconds would take 21.3 minutes, assuming we can keep up that pace and remember which was the best combination.

This is where solver comes to the fore.

Applying Solver

To apply solver we need to define a series of requirements, rules and constraints.

These requirements, rules and constraints guide solver and set limits which allow solver to quickly narrow in on the answer.

What are our rules

Our main requirement is to minimise the difference between the value of the 2 buckets.

The difference between the 2 buckets in our example is cell G11, the sum of Bucket 2 values minus the Sum of Bucket 1 values.

We want to have G11 as low as possible but greater than or equal to 0.

 

We also know that an item can only be in Bucket A or Bucket B, it can’t be in both and can’t be Broken apart.

That is 2 Constraints for each Item

Firstly The Total column must be equal to 1

Secondly the Buckets Values must be Integers

We also know that the Total Number of Items is 8, this is another constraint.

We will discuss how these constraints are used in the next section

The Solver Window

This section will explain the solver window and its use in defining the problem within solver.

A Blank Solver Window

A Filled Solver Window

Set Target Cell:

This is the Target cell which is the cell which you are trying to solve the problem for.

Our Target cell is G11, The difference between the 2 Buckets values

Equal To:

The Equal To: section defines what we want to do with our Target Cell.

We want to achieve the same value in each Bucket and so the difference between the Buckets will be 0.

It might sound strange but we don’t want to minimise that difference. A minimal value will be achieved when all the Items are placed in Bucket A, as our equation for G11 will then have 0 – Total which is –Total, which is more minimal than 0.

Another way to constrain this is to Change G11 to =Abs(G10-H10)

This allows us to use Min as an Equal To: Value

But for now we can just leave G11 as =G10-H10 and we will set the Equal To: section as 0.

By Changing Cells:

Changing Cells: refers to the cells which will be modified by Solver to try and solve the problem.

We want to let Solver change the number of items in each bucket, this is the range: $C$2:$D$9

Hint: You can try the Guess button next to the Range Reference and Solver will take a Guess at what cells the problem is dependent on.

Always check this if you use it, especially in complex models.

Subject to the Constraints:

Constraints are the rules which define the limits of the possible solutions to the problem

We will add several constraints for our rules:

1. The Total column must be equal to 1 for each Item

2. The Bucket Value must be an Integer

3. The total contents of the 2 buckets must be 8 items

4. You could add a further constraint that each Bucket should hold the same number of items

Hint: As a general Rule, Under Constrain rather than over constrain! You can always add more constraints later.

To do this we will use the Add Constraint Button

1. We need to add a constraint for each cell in the Range E2:E9 that it is only allowed to be = 1

This constraint must be applied for each cell in the range E2:E9

2. We need to add a constraint for each cell in the Range C2:D9 that it is only allowed to be an integer

This constraint must be applied for each cell in the range C2:D9

3. We need to add a constraint for the Total of the 2 Buckets, E10=8

You can Change or Delete Constraints if you make a mistake by selecting the appropriate constraint and using the Change or Delete Buttons

Save and Load Solves Parameters

Selecting the Options Button there is the Option to Save Model and Load Models.

Hint: The Save/Load Models has been shifted onto the main Solver dialog in Excel 2010.

Using the Save Model and Load Model options you can Save and the Load the Solver Parameters for your model. The Save Model saves the parameters in a Range of cells as shown below.

This allows an easy way to actually setup and/or change the solver parameters.

Hint: Setup one constraint using solver then Save the model. Edit the model on the worksheet and re-load the model as required.

Note: That the parameters although when saved show as True/False or Numbers are all Excel Equations, see above.

This means you can edit them to change the Constraints and Parameters as required and re-load them into solver.

I have included 3 sets of Parameters for our model.

These are:

  • Base Case – Forces bucket values to be equal, Allows uneven bucket counts
  • Equal Sized Buckets – Forces each bucket to contain the same number of items
  • Force an error – Which forces an error in the solver model

Load each model and try them at your leisure.

Running the Solver Model

Warning: Solver is a computationally complex add-in, so once your model is setup, Save your Workbook.

Prior to running the model there are a few parameters we should look at to ensure the model solves correctly.

On the main Solver window select the Options button. (Some of these parameters are on the Main Solver window in Solver 2010)

Generally you can accept the defaults but in this case we will change the following

Assume Linear Model – Select

Assume Non-Negative – Select

Note: Solver in Excel 2010 will return a better answer without these 2 parameters enabled by default

The other 2 parameters which you may need to change from time to time is

Precision: Precision is a number from 0 to 1 and higher means more precise

Tolerance: Tolerance shows how far away from a Number, an Integer constraint is allowed to be

The use of the Estimates, Derivatives and Search parameters are beyond the scope of this post. I direct you to the Excel Help on these subjects, by selecting the Help button.

Run the Model

To Run the Model, select the Solve Button from the main Solver menu.

The main status bar in Excel will flash up a number of statistics about the internal workings of the Solver add-in. Generally these flash by and are too fast to read. If a model is too complex it may stall and you won’t see any movement for a while. Solver generally recovers from these problems itself.

 

Once the Solver model finishes it will display a dialog of the results and allow you to do several things

First thing to note is that “Solver Found a Solution.

If it has found a solution, the worksheet cells will be changed to show the solution

You now have 4 options:

  • Run a Report
  • Save a Scenario
  • Return to the model
  • Check Your Results

Run a Report

Run a report by clicking the report you want.

A new sheet will be added to your workbook depending on the report but will be called:

  • Answer Report 1,
  • Sensitivity Report 1
  • Limits Reports 1

etc.

Note, that not all reports are relevant at all times, depending on the Constraints you have applied.

Save a Scenario

Selecting the Save a Scenario button takes you to the Save Scenario dialog.

 

Type in a Name and the Scenario of your model is saved as a Scenario.

Scenarios as available for use in the Scenario Manager, which is accessed from the Data, What-If-Analysis Tab

Return to the model

You can return to your model and either:

  • Keep Solver Solution
  • Restore Original Values

Check the Results

Solver is probably the most Black Box’ish of systems within Excel. As such any results it puts out must be manually checked for suitableness before further use.

These checks for realness, should as a start confirm that the results meet all the criteria supplied.

Are the results roughly what were expected?

Are any Minimums or Maximums violated?

 

What If Solver Doesn’t Find a Solution?

From time to time Solver will return with an error that a “Solver could not find a feasible solution.

When this happens it is indicating one of several possibilities:

  • Your model is over or under constrained
  • Your model constraints are impossible to meet
  • Your model constraints have an error

Start by checking the current constraints for errors and ambiguities

Eg: in our case we have 8 items so requiring the Count of the two buckets to be 20 is impossible to meet

 

My Solver Answer has Strange Numbers?

In solver up to and including Excel 2007, solver would commonly return numbers like 3.5E-18.

This is 0.0000000000000000035, which is effectively 0

If your model returns these, feel free to go through the model and change them to 0, in our model we should also check as the corresponding 1, may in fact be 0.9999999999999999965.

It should be noted that this problem in Solver in Excel 2010 does not occur as often but will still occur.

 

What and How have you used solver in the past?

What and How have you used solver in the past?

Let us know in the comments below:

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

132 Responses to “Excel Tables Tutorial & 13 Tips for making you a Data Guru”

  1. Peter H says:

    Chandoo, I have only been using data tables for a few weeks & have discovered that they can be used to have charts dynamically expand to take in new data.
    Simply set up the chart data in a block with appropriate headings (headings must be text, not formula).
    Convert it into a table, select the whole table and insert a chart.
    Format the chart as required.
    When new data is added the the table and chart will expand to show the data.
    The only problem I have found is that the last column of data must show a number when inserting the chart- a blank, #N/A and perhaps text will cause wierd changes in the chart. However this only occurs when first inserting the chart once set up it accomodtes blanks & #N/A etc. This is easily over by adding a temporary number when required on setting up the chart then replacing it with the correct formula when the chart is complete.
    This seems to be a lot easier than using offset formula for the series .

  2. Dan Murray says:

    Nice post. I've been using Pivot Tables for years but haven't used the "table" button until now.

  3. Michelle says:

    This is great! Never used data tables before but it helps a lot. One question though, if I try drag your SUMIF formula across a row, different columns are selected in the formula. Normally you can make the columns static in a formula by using "$" - any suggestions on doing the same here?

    • Leah says:

      Convert the data to range. Enter your SUMIF formula, then convert it back to a table.

      • Richard says:

        This doesn't work....well, it only worked one way when I tried it. I had the data as a table and had created some SUMIFS formulae on another sheet. I coverted the data table to range and the formulae all changed to use range references. But when I changed the data back to table, the formulae stayed the same.

    • David N says:

      Creating absolute structured references is a bit awkward but not difficult.

      Some Column as a relative reference
      =SUM(Table1[Some Column])

      Some Column as an absolute reference -- repeat the column name
      =SUM(Table1[[Some Column]:[Some Column]])

      The Some Column cell of the current row as absolute -- repeat the column name -- with the Other Column cell of that same row as relative
      =SUM(Table1[@[Some Column]:[Some Column]],[@Other Column])

      The range of Some Column to Other Column as entirely relative -- repeat the table name
      =SUM(Table1[Some Column]:Table1[Other Column])

  4. Nimesh says:

    Nice post. Nice to see such useful options in 2007.

  5. Frederick says:

    hi Chandoo,

    How do you "record" the screen captures of the screens that you need to show into the animated gifs? Do you use a special software for it?

  6. Doug says:

    Thank you. This is truly a gem that will save hours and hours of time.

  7. Robbert says:

    Nice post! However, in a basic form this functionality already existed in Excel 2003 as a 'List' (ctrl-L). So it not needed to convert the table back to a normal range for excel 2003 users.

  8. Michael says:

    Chandoo,
    nice post. Seems to be a useful feature. Does data tables exist in Excel2003 as well?

  9. Chandoo says:

    @Peter H: Very cool tip about the charts and data tables.

    @Dan: Tables are very useful and simple. Pivot can be very powerful for data analysis, but tables are good for maintaining databases.

    @Michelle: The sumif formula in the article is written outside the table in a cell. If you write formulas in and copy (ctrl+c) and paste them, then the references are not changed. But if you drag the cell (thus auto-fill), then the cell references to table columns are changing. Not sure why excel would behave like this.

    Also, inside the table, you can use [#this row] operator to calculate values for that row alone.

    @Frederick: I use camtasia studio to record the screen. It is a nice software. You can test it from techsmith website.

    @Doug: You are welcome 🙂

    @Robert: My mistake, I meant version earlier than excel 2003.

    @Michael: yeah, they are called as Lists. Press, Ctrl+L to create one.

  10. [...] since I have learned the tables feature in Excel 2007, I have fallen in love with that. They are so awesome and so user [...]

  11. bazlina says:

    i kept saying OMG WOW THATS AMAZING over and over.
    i'm quite new with excel so your blog helps a lot and this post, is truly great. thank you!

  12. [...] Microsoft Excel Table Tips and Tricks – Learn Data Tables and Become a Data God | Pointy Haire...By chandoo.org October 16, 2009- ???????Excel???????????????……?X?…… [...]

  13. [...] Microsoft Excel Table Tips and Tricks – Learn Data Tables and Become a Data God | Pointy Haire...By chandoo.org October 16, 2009- ???????Excel???????????????……?X?…… [...]

  14. [...] Microsoft Excel Table Tips and Tricks – Learn Data Tables and Become a Data God | Pointy Haire...By chandoo.org October 16, 2009 [...]

  15. g7 says:

    4. Bye, bye cell references, welcome structured references

    it does not beat absolute reference to cell i.e $A$1, because if named range is used, it will not copy correctly if u use cell dragging horizontally... it will move to the next name range

    • Joe Blauh says:

      This is a huge negative for "structured" references. Excel created a nifty tool that requires me to accept a significant loss of functionality if I decide to use it. It also prohibits dragging cell references to change formulae, so if I drag to fill, I have to click into the cell to manually edit the reference cells to what they should be instead of being able to drag the cell reference box back to the correct column. A small step forward and a giant step back. Or, more succinctly, Microsoft - 'nuf said.

  16. sb says:

    Chandoo,

    I have a question on this. In my sheet I have the "Total Row" added. In that I take an average of a column values and I need to reference this final Average value elsewhere. How Can I reference this specific "totalled average cell" such that when new rows are added the same cell is taken?

    As of now, since the total is at the bottom of the table, when a new row is added the cell id of this "total average" row keeps changing. I tried to move it to the top of the table to keep it constant but I couldn't.

    thank you
    sb

  17. Chandoo says:

    @SB.. you can use the [#totals] tag in the structured reference to total row else where like this:

    =Table1[[#Totals],[Column1]] This will work even when you add more rows to the table.

    • Siddhant Gupta says:

      Hi Chandoo,
      when i use this code it always shows a #Ref! error.Can you please help me to fix it?
      Thanks!
      Siddhant

  18. sb says:

    Thanks @chandoo.

  19. [...] will save precious amount of time when you are busy modeling. (100s of tips on keyboard shortcuts, excel tables, formulas, charting & [...]

  20. [...] Select your list of products (or invoices or cats) and make it in to a table. (here is a helpful tutorial on excel tables). [...]

  21. V S Venkatraman says:

    Dear Chandoo (Excel Guru)

    Thank you very much for sharing such useful tips... now I feel more confident in analyzing a data with Excel....

    Regards

  22. DangerMouse says:

    Chandoo,

    Where referecing table columns as range input to formulas such as sumif(), is it possible to get Excel to treat the reference as static for "fill" purposes?

    Cheers,

    Steve

  23. Chandoo says:

    @DangerMouse.. you can use ctrl+c ctrl+v instead of drag fill technique to treat the table references as static.

  24. olegko says:

    How to make absolute reference on Table column?
    I have Table1 and use such formula:
    =SUMIFS(Table1[Pay],Table1[Month],G9)

    I want to “freeze” columns “Table1[Pay]” and “Table1[Pay]” in formula (like $A:$A).
    How to do it?

  25. Chris says:

    Looking at article like these make me sad 🙁 - still being laden with 2003 really goads when you see so many fantastic improvements just out of ones rech like this......

  26. [...] Excel Tables, a newly introduced feature in Excel 2007 is a very powerful way to manage & work with tabular data. I really like tables feature and use it quite often. If you are new to tables, read up Introduction to Excel Tables. [...]

  27. Avinash Ahire says:

    I want to learn some excel course from you.
    If you have any training centre in Mumbai, Please let me know..
    Excellent Work!

    Thanks
    Avinash Ahire

    • javed sheikh says:

      i want to learn some advance tally course from you
      if you have a training center in mumbai any location, please let me know
      Excellent work!

  28. 5.antiago says:

    Is there a better way than ctrl-c-ctrl-v to expand the ~ifs() formulae across a row while keeping the absolute references to the auto-named ranges in the data-table? I know this has been mentioned a few times in the comments but I'm hoping someone cleverer than me might re-look at this...

    All I've got so far is transposing my new table I'm trying to create so I'm dragging down instead of across, which holds the named column references, but I would prefer a dragging across solution

    This is my first post on your website Chandoo, but I've been reading for a couple of weeks. It's a fantastic site! Thanks for all your efforts

  29. brices11 says:

    I love it, I love it, I love it. Don't know how many errors I run into because of bad cell references this should help mitigate this.

  30. PM says:

    Ok REALLY stupid question, I created the table and I have been putting in formulas using the column names, how do I "without using my mouse" select the table name from the tool tip ( or drop down) that shows up. Currently I have to scroll my mouse down to the right column name and then click it add the bracket etc. This also applies for when I use formulas in general. Please help, I am trying to be "Mouse free" 🙂

    I have been using Excel forever this is amazing.

  31. Jim Morley says:

    Hi Chandoo,

    I am using Excel 2007.

    I am using an excel workbook to enter data for several different sites (each site has its own worksheet). I want to establish a summary worksheet showing the consolidated data accross all sites so as I enter data into the individual site worksheets the data is also replicated in the summary worksheet which is then sorted by site to show the consolidated view of all sites. Each of the site worksheets have the same data headings which will be replicated in the summary worksheet.
    Can you please give me some advice as to how I can go about this?

    I know how to use the basics of excel but know nothing about using databases like Access so I would prefer to continue to gather the information in excel if this can be done.

    Hoping you can help me,

    Jim Morley

  32. [...] The Data Table function should not be confused with the Insert Table function. [...]

  33. [...] Excel 2007, Microsoft has introduced a powerful and useful feature called as Tables. One of the advantages of Tables is that you can write legible formulas by using structural [...]

  34. padmanarayanan says:

    Chandoo,
    I really missed you discount offer last week or so,That day i could not access the internet.Any chance of getting discount offer, i am really interested in joining your course.pl let me know.

  35. Jen says:

    Chandoo, thanks a lot for all your tips and tutorials. Your tutorials are really great and easy to follow!!!

  36. Shanmugavel says:

    Hi, Can i access Excel 2007 table via code - JavaScript?

  37. Jonathan says:

    WOW!
    I've spent days organising a "table" of my own (without knowing it) writing formulas,creating helper columns and generally getting stuck and i just figured out that tables and pivot tables do all this in minutes. I dont know whether to feel downhearted or elated that i've learnt this! (all be it too late)

  38. [...] Learn Conditional Formatting 3. Making Dashboards using Excel 4. Project Management with Excel 5. Working with Excel Tables Topics & Archives 1. Learn Excel - Topic-wise 2. Charting Tips, Tricks and Tutorials 3. Ask an [...]

  39. Debaranjan samal says:

    Hi ,

    I need a vba for excel training in delhi, kindly suggest regarding this..

  40. Deb says:

    How do I get the AutoFormat of Double-Bars in XL 2010? It was so easy in 2003, but I cannot find a way to do it, w/o VBA, in 2010! It can't be that hard.

    In 2003, Format, AutoFormat, choose the List 2 style. It formatted rows in groups of twos, or pairs. Very handy in lots of cases.

    Any ideas?

    Thanks

  41. Premalatha says:

    I have become a fan of tables now. 🙂

  42. Premalatha says:

    Hi Chandoo,

    I used structured reference but when I close and open again, they have all become cell references! Is there a way to fix this? I am using 2010. Thanks,
    Prem

    • Prasad says:

      Even I have the same problem and worst is it when we add new rows the formulas now do not get changed as it is now having cell references 🙁

      Regads,
      Prasad DN

  43. Muhammad Bilal Yousaf says:

    Dear Sir,
    i want tech the micro soft excel data table and function for opperating the micro soft excel. please give send the tip of micro soft excel.

    with best regards and wishes,

    Muhammad Bilal Yousaf

  44. FarooqAsim says:

    Dear
    I went to some new learn work in excel
    latest
    best Regard
    Farooq Asim

  45. Linda says:

    Absolute references:
    As Chandoo says, these move if you use drop and drag.  However, if you highlight the required cells, place the cursor in the cell to be copied and use Ctl Enter then the formula copies keeping the references "absolut"

    Linda

  46. [...] have set up this data in an Excel Table called as tblSales so that it is easier to write [...]

  47. Eric says:

    I've tried to name tables so that I can reference them in functions, etc... but I'm not having any luck getting the name to stick.  I can click in the area to the left of the function button and type a new name for the table, but clicking outside of that causes the name to revert back to what it was (for instance, 386, or 3).  Thoughts?

    • Hui... says:

      @Eric

      Select any cell in the Table you want to rename

      You should see a Table Tools, Design Ribbon

      Select that Ribbon and on the Left there is a Table Name: dialog

      Change the name and press Enter

       

  48. [...] wrote a great post several years ago that explained the basics of Excel tables and provided a number of tips and tricks related to them. [...]

  49. Naresh Koganti says:

    How to rename a Data Table name in Excel.

  50. vimal says:

     i like you your website, but i quesestion i wil  written to excel in accountant but evry time name party not  incuding, so anything i find to party name  is all ready this excel in ready name ,so you my question solve and reply to me my email id vimal_jariwala15@yahoo.ca  

  51. Nitin K. says:

    Hi,

    How can one add zebra lines in table rows in Office 2010?

  52. Paul Nickell says:

    I have learned so much in the last few weeks since joining in here. Well done.
     Now I have a query that I need hlep with. The company I have started working for uses loads of data. Reports are exported to Excel then sorted etc etc...
     The Key ref numbers are numeric, 12345.1 and 12345.10 etc etc. Excel will obviously sort the .10 above the .1 - Its an habbit of the reporting software to create a .1 and not .01 Is there anyway within Excel to block alter all the .1's to .01's? I'm talking thousands of them, not just a handful that could be formated as text manually.

  53. [...] Use Excel Tables: Since Excel 2007, we can create tables from structured data and write formulas, create charts that refer to dynamic ranges with ease. Click here to know more about tables. [...]

  54. [...] the dashboard on the Property Register converted to an Excel Table (a 2007+ feature that many are still unaware of) enables the use of  Slicer selectors in Excel 2013 to quickly give a dashboard feel. It’s [...]

  55. Steve Jones says:

    Great site, and your instructions are so easy to follow. Thanks so much!
    On sheet 1, I have a table of names and demographic information for each.
    On sheet 2, I am using the same table of names but different data across the columns.
    When I add a New Name to the table on Sheet 1, I have to manually extend the table on Sheet 2, to expose the new name.
    Is there a way to automatically expand the table on sheet 2, to show the new name added to the table on Sheet 1??
    Thanks so much
     

  56. Paddy says:

    Has anyone tried using named tables as data sources outside of Excel? For instance, referencing the table for a mail merge? If so, how have you got it to work? Thank you all!

    • Colleen says:

      Yes.  I use tables in a mail merge.  There's no trick (I can think of) to it different than using any other Excel data to mail merge.  My own notes for mail merging mention that I open the Excel spreadsheet first and that I need to make sure that the active sheet is the sheet with the table I want to use on it.  I do seem to have had problems if a different sheet is the active one.

      There IS a trick to making sure your Excel formatting (like number formatting for $, etc.) comes through.  But that is true whether or not you are using a table.

  57. Colleen says:

    I like to say, "If you're not using tables, you're doing it wrong."  Or at least 90% of the time you should be using them!

    I would like to say, "Tables are the best thing since sliced bread", but it then occurs to me that sliced bread is highly overrated.  I can slice my own loaf much quicker than doing many of the things manually in Excel that tables make easier.

    I LOVE tables!  They have changed how quickly and awesomely I can analyze and present data. 

  58. Gijs says:

    Hi Chandoo, another awsome tutorial.

    Can you expand the VBA so that i can leave some categories blank and the table will show ALL entries for that category?  (eg all Customer Types or all Regions)?

    Thanx, Gijs. 

  59. [...] ourSales[month] refers to the month column in the ourSales table. Works only in Excel 2007 or above. Know more about Excel Tables. [...]

  60. Chandra says:

    So I created a data table and wrote forumlas using the data table and column names.  It all calculated out beautifully.  HOWEVER, now that I want to add lines to my data table, none of the formulas are seeing the added data.  I've gone in to expand the range of the table, etc.  But still no luck.  So stinkin' frustrated :/  Any advice??

  61. [...] best way to create a tracker is to use Excel tables. Set up one with 4 columns – Employee name, vacation type, start date & end date, like [...]

  62. Reena says:

    Hi,
    I need to convert some data into columns can anyone help me?
     

  63. [...] Visit link: Microsoft Excel Table Tips and Tricks – Learn Data Tables and … [...]

  64. Louis Moodie says:

    Dear Chandoo,
    I have done much research and your Excel offering is certainly highly rated and I would like to subscribe. I am using Excel 2011 for Mac. Will the course content be compatible? I assume it will but perhaps you have been made aware of some idiosyncrasies?
    I look forward to hear from you.
    Louis
    P.S. Are you aware that your reference to "GOD" will be offensive to many in the Biblical-based faith community (of which I am a practising one)? I suspect you are using it in a different context but it does detract from your brilliance.

  65. [...] how your data for the projects/entities being tracked laid out. We will use the Excel data tables [structured references] to help us [...]

  66. [...] how your data for the projects/entities being tracked laid out. We will use the Excel data tables [structured references] to help us [...]

  67. [...] select any cell in range and press CTRL+T. Specify a name for your table from design tab. Read introduction to Excel tables to understand [...]

  68. [...] Introduction to Tables, Introduction to structural [...]

  69. Rina says:

    Dear Chandoo,

    Just one word "Amazing" I like this site 😉
    Thanks for sharing all of these

    Good Luck

  70. [...] wrote a great post several years ago that explained the basics of Excel tables and provided a number of tips and tricks related to them. [...]

  71. arindam says:

    hi chandoo,
    I m unable to get the point 6. plz help.

    • Hui... says:

      @Arindam
      The Menu's Chandoo shows as Pt 6 vary from Excel version to Version
      They are accessible by
      Click in a PT anywhere
      A menu Bar will appear with Pivot table Tools
      It may have a Options Tab and a Design Tab
      Select the Design Tab
      You should see the options shown in Pt 6 here

  72. […] am sure you all are aware of a feature called as Excel Tables OR Structured References in Excel. Excel Tables is (in my opinion) the best way to store your raw […]

  73. Mona says:

    Hi, in point number 6 of http://chandoo.org/wp/2009/09/10/data-tables/
    Total your Tables without writing one formula
    The ability to summarize data with pivot tables is extended to excel tables as well. You can add total row to your table with just a click.

    What more, you can easily change the summary type from “sum” to say “average”.

    How do you change the summary type from sum to say average?

  74. Denis J says:

    Table Text Filtering - is it possible to have column 1 ( in this case named "WO") in the table filter automatically based on the date referenced in another worksheet cell within the same workbook?

    Thank you 🙂

  75. Vinay Chande says:

    Excellent presentation...it would surely interest the most excel fearing people I knw

  76. […] LinkExcel data table is a series of rows and columns with related data that is managed independently. … Excel 2007 has some great pre-defined table formatting opt…chandoo.org […]

  77. Arif says:

    how can add last paid amount in vacation track.

  78. ND says:

    Tried removing the filters but it was difficult. Any reason for this?

  79. Valuable information. Fortunate me I discovered your website unintentionally,
    and I'm surprised why this coincidence did not came about earlier!
    I bookmarked it.

  80. Mark says:

    Going to drop this comment here, since I could not really find a suitable post otherwise. I am not sure if I am overthinking this per usual and missing a very simple remedy - but nonetheless I find myself at a dead end.

    Anyone know if it is possible, and if so, how to have multiple headers in a table? I know it sounds counterintuitive but I would like a way to pivot a bulk set of data (set in an Excel Data Table) but have the option to choose 1 of 2 Options when choosing my data header for the Pivot.

    Let me try and explain a scenario. So each row has an Account, Part #, a specific week ending date units sold, and a specific week ending date unit dollars. For each account, we sell maybe 5-7 products. So Retailer A has 5 unique rows, Retailer B has 7 unique rows, yadda yadda.

    I have 4 tabs, very similar of one another, the only variable is the year (specified by the tab) - or - table name ... and the removal and inclusion of obsolete and new products.

    Our Sales weeks are Sunday-Saturday. So, I have 2 column headers that read 11/15 Units and 11/15 Dollars; for this past week.

    However, If I wanted to compare this past week to last year or 2012, using Power Pivots, I would not be able to - since "week endings" do not lineup. That is to say in 2013 Week 46 (this past week-end week) correlates to 11/16.

    So I would not be able to do a 1:1 comparison easily within a Pivot due to the variation in dates. So logically, I would need some sort of common denominator. I would imagine this would be Week "X." So essentially two separate (or hierarchy?) column headers. I would either need "Week 46" act as a parent - above both "11/15 Units" and "11/15 Dollars" ... or alternatively two separate "co-headers" right above them: "Week 46 Units" and "Week 46 Dollars"

    This way, I could compare multiple Week Ending sales data, across multiple tables, using a Power Pivots, based on a common property.

    Does anything like this exist? I feel like I would have come across it by now if it does.

    And to note, I cannot simply just change the way we handle data to reflect a Week # and omit the XX/XX date methodology. I wish I could, cause that would be abundantly easier.

    • Hui... says:

      @Mark
      Can you post the question at the Forums and include a sample file?
      http://chandoo.org/forum/

    • Richard says:

      Not sure how 11/15 or 11/12 can reference a week as it refers to a month!

      If you use the function WEEKNUM(date) with date being the date of the Saturday or Sunday, it will refer to the same week whatever year you are looking at.

      So your "co-headers" could be =WEEKNUM(date)&" Units and =WEEKNUM(date)&" Dollars".

  81. […] Excel Data Tables – An Excel table consists of a series of rows and columns with related data that can be managed independently.  Most work in Excel happens inside a table. A table allows users to easily create formulas to make calculations related to one or more rows and columns. Some examples of formulas include the sum of a column, an average, a maximum or a minimum value. For more on tables, visit this tutorial. […]

  82. AKIN KARAMAN says:

    very useful informations. billion thanks.

  83. sebastian says:

    Why using tablet format on a file makes it so big?

    I had to change all my formulas to references because the size of my file was to big to work.

    Any advice ?

  84. Jake Burns says:

    Hello Brother,

    Your website is awesome. Thank you for all your work. I cannot be as your ordain in your 3rd paragraph as I believe in the One, True, Almighty God. But I can try to be the best I can.

    Thank you sir for all your work and sharing.

  85. Jeffrey Smith says:

    Chandoo,

    As usual, this article was very well done and I thank you for sharing. I'm posting this comment about some trouble I had with Tables, just as a warning for others who might stumble into it, too.

    So readers know how much time this cost me, I'll admit this issue took me down a 5 day journey, including an Office 2010 Repair, then an Office Uninstall both of which threw similar errors, so I found an MS Fixit Tool that seemed to describe my situation and ran that but it, too, threw a similar error, and then found a 3rd party utility that claimed to clean up the residue of Office Uninstalls that went wrong, but, it, too, threw the same similar error, but it did at least remove Office from Programs and Features, so I proceeded to re-install Office but that re-install also erred out with the same similar error. After scouring the Internet for this error as well as the original issue (below) that made me think something was wrong (and unbeknownst to me that the cause was a Table issue), I concluded that I must have a virus on the system (despite being current on all my Updates and running 24/7 Virus and MBAM anti-malware) and proceeded to do a clean re-install of Windows 7, Office 2010 (as well as all associated Windows Updates, all my browser Add-ons and preferences, and all my programs, etc. but I took the time to also do something I should have done a long time ago and set up a cloned image of my hard drive when done so if I have any further issues, a re-install of Windows and everything else will be a 20 minute walk in the park instead of the nightmare this has been.

    Anyway, back to the Table issue: While working on a large project that has some 10 Tables in it, one of which had Table Headers that were formula driven (these were incremental Date Formulas), that somehow were subsequently getting Pasted as Values. I was building these Tables with Code, and therefore wasn't seeing the warning that Converting a Range to a Table would convert Formulas to Values (and since I hadn't ever done this before, didn't know that message presented if done manually). In my subsequent endeavors to go back to earlier versions where the formulas were still dynamic, I found I could Copy the formulas from the older files, but no matter what I did, I couldn't Paste them as Formulas. This capability is an essential part of Excel, of course, but it wasn't until I had re-installed Windows, Office (et al), and found out that the problem was STILL there, that I finally figured out that it couldn't have been a virus, and finally moved the file to another PC, where I confirmed that the problem was in THE FILE. So, amongst many lessons I learned in this journey was that if you have to have Formulas in your Table Headers, then build into your code (or manual process) a routine that places a copy of your header row under your 'nominal' Header Row (and hide it so you don't have duplicates), but reference the hidden row as your Table Headers.

    Hope this helps someone as there is a LOT of other forum posts out there that have to do with Excel Copy/Paste issues but I did not find this as a cause).

  86. AN says:

    In excel Table a copy paste is not working the way it should. Within a Table I am trying to copy a cell's content into another cell it copies totally different value. Need assistance on how to deal with it. Thanks.

    • Danny Saville says:

      I found that I can not paste values in cells within a Data Table- whether they are copied from within the table or outside it (although the cells in the Data Table have NO foumulas!).
      I hope someone has an answer to this (i've been searching for a long time).

  87. Roy Middleton says:

    Hi Chandoo

    I'm trying to get my head around Excel Tables and Structured Referencing
    and struggling to see how something like the following could be accomplished using this methodology: IF "A1" AND "B1" ARE BLANK AND "C1" AND "D1" ARE NOT BLANK AND "E:E,E1>1", "DUPLICATE","UNIQUE". is it possible?

  88. Walter says:

    When the header positions change my formula take the original header positions' data. How do I address the issue?

  89. veronica obi says:

    pls l need you to teach how to use excel from the beginning l have lost touch about some of the functions

  90. B RAMA GOPAL says:

    IF I HAVE DATE AND PLACE IN ONE COLUMN HOW CAN I MOVE IT INTI TWO COLUMNS
    27/05/1956 OVL-DELHI
    10/09/1956 AHMEDABAD
    30/01/1961 DELHI

  91. Jose Gonzalez says:

    Hi. Thanks for having this amazing web site. I wonder if excel tables have the capability to add more than one total row.

    Thanks,

  92. […] The vertices of the regular octahedron with its centre at origin will be as below. let us enter these in excel worksheet as Dynamic tables […]

  93. Louis Ortega says:

    Once a table is created how is it updated? Say that the table needs to be updated with changes once a month besides VBA and doing it manually how is data refreshed in a table? Is there an Excel formula or module to make changes?

  94. Abhaya says:

    This is an amazing post. Have been using Excel for about 8 years now but never came across this.
    Thanks a ton, Chandoo 🙂

  95. Stephen says:

    Tables make it easy to create dynamic charts, but how can you use the filtered data to create a dyanamic title - eg checking that there is a unique value in one column and then using that?

  96. […] Excel Data Tables – An Excel table consists of a series of rows and columns with related data that can be managed independently.  Most work in Excel happens inside a table. A table allows users to easily create formulas to make calculations related to one or more rows and columns. Some examples of formulas include the sum of a column, an average, a maximum or a minimum value. For more on tables, visit this tutorial. […]

  97. Sandeep Kothari says:

    Gr8 article; something expected of you.

  98. pushpendra says:

    thanks for very nice and informative post.

  99. […] next article is a review of another important feature: Data Tables. If you deal with data in Excel, you have probably come across this feature or you should. Tables […]

  100. Venkata Ramanan Krishnamurthi Iyer says:

    Sir,
    I am using excell in iPad.
    And I would like to know if the shortcut tips you have explained are usable in iPad keyboard also.
    I am a beginner in excell usage and hence this clarification.

  101. arun mathur says:

    hi

    despite my efforts I could not resolve
    Sheets("rwshow2").Range("TC[#ALL]").advancefilter Action: xlFilterCopy , criteriarange:=Sheets("rwshow2").Range("S1:U2"), copytorange:=Sheets("fltr").Range("B10"), unique:=True

    please help what I am doing incorectly

    thanks and regards

    Arun

Leave a Reply