Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel

ResolvedVersion 2007

Ian has attended:
Excel Intermediate course
Excel Advanced course

Excel

I need to run a pivot table from a spreadsheet that has a differing number of lines of data in it each day.
The table works fine if there are less lines of data on a particular day, but fails to pick up any additional data if the spreadsheet has extra lines. How do I set the range for the Pivot Table so it automatically picks up all the data in my spreadsheet?

Thanks.

Ian Robertson

RE: Excel

Hi Ian

There is a way of running a pivot table where there are a variable number of rows of data added.

To do it you have to use a range name with a dynamic formula to define the source range for pivot table. Then as new items are added to the table, the named range will automatically expand.

Start by clicking in any cell in the range of data then
1. Select Formulas, Define Name.
2. Type a range name eg Database.
3. In the Refers to box type the following:

=OFFSET(Data!$A$1,0,0,COUNTA(Data!$A:$A),N)

where Data is the name of the worksheet containing the database.

4. Replace N with the number of columns in the Database range.

Then when creating the Pivot table

1. Select Insert, Pivot Table.
2. In the Select a table or range box type Database.
3. Cick OK to place the pivot table into a new worksheet.

Now whenever new records are added all that's needed is to select Povot Table Options, Refresh.

If there is likely to be a variable number of columns then replace N by:
CountA(Data!$1:$1)

This method avoids the need for macros or VBA code.

Regards
Doug Dunn
Best STL

RE: Excel

Hi Doug,

Many thanks for that!

Regards,

Ian.

Wed 11 Jan 2012: Automatically marked as resolved.

Excel tip:

Generating Random Numbers

To generate a random number in Excel use the = RAND() function.

The value returned will always be between 0 and 1. To convert this to some other random value, you will need to multiply the result by the highest number you want to consider. For example, if you wanted a random number between 1 and 25, you could use the following code line:
= INT(25 * RAND()+ 1)

Since RAND() will always returns a value between 0 and 1 (but never 1 itself), multiplying what it returns by 25 and then using the Integer function INT on that result will return a whole number between 0 and 24.

Finally, 1 is added to this result, so that x will be equal to a number between 1 and 25, inclusive

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.