Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default PivotTable with No Source Data

Hi All,

I have a workbook that has data on one sheet that is used to feed a
PivotTable on another sheet. I used a dynamic named range to allow the
PivotTable range to grow/shrink without including blank rows. I also
have macros coded to automatically refresh the PivotTable every time
the sheet that it's on is activated.

This setup works beautifully until all of the source data is deleted
(i.e. the only thing left on the sheet with the data is the row with
the column headings). If all of the source data is deleted, I receive
the following message when the PivotTable sheet is activated:

Run-time error '1004': This command requires at least two rows of
source data. You cannot use the command on a selection in only one row.
...."

I understand what the message means (a PivotTable requires more than
one row of data) but can anyone recommend an elegant way to handle this
situation? As the spreadsheet won't be used by me, I'd like the
solution to allow users to enter and remove data freely.

Any assistance would be greatly appreciated.

Thanks!
Kris

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default PivotTable with No Source Data

Hi

However you are defining your dynamic range, make the row count element
the maximum of 1 and rowcount.
something like
=OFFSET($A$1,0,0,MAX(2,COUNTA($A:$A)),12)
You have to have a header in row 1, hence COUNTA is bound to return 1,
so just force it to be 2 if there is just the single header line.

--
Regards

Roger Govier


wrote in message
oups.com...
Hi All,

I have a workbook that has data on one sheet that is used to feed a
PivotTable on another sheet. I used a dynamic named range to allow the
PivotTable range to grow/shrink without including blank rows. I also
have macros coded to automatically refresh the PivotTable every time
the sheet that it's on is activated.

This setup works beautifully until all of the source data is deleted
(i.e. the only thing left on the sheet with the data is the row with
the column headings). If all of the source data is deleted, I receive
the following message when the PivotTable sheet is activated:

Run-time error '1004': This command requires at least two rows of
source data. You cannot use the command on a selection in only one
row.
..."

I understand what the message means (a PivotTable requires more than
one row of data) but can anyone recommend an elegant way to handle
this
situation? As the spreadsheet won't be used by me, I'd like the
solution to allow users to enter and remove data freely.

Any assistance would be greatly appreciated.

Thanks!
Kris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default PivotTable with No Source Data

Thank you very much Roger ... that worked like a charm! :)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default PivotTable with No Source Data

Oooops, spoke too soon. The solution worked in the sense that it
produced a blank PivotTable without generating an error but it caused a
problem with a date column in the PivotTable that's being grouped.

The PivotTable contains a date column that's grouped by Year and Month.
Refreshing with a blank data source destroyed this grouping. My guess
is that this is because you cannot grouping a column with blank rows.

Any ideas?

Thanks,
Kris

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default PivotTable with No Source Data

Hi Kris

Since you say you are running macros, could you not just ensure that
there is a single "row" of data by just writing a date to cell A2 of
the data sheet e.g. A2=TODAY()
Then, the count will still include just one "blank" row of data as well
as the headers, but the grouping will work because there will be a valid
date in row 1. It will not affect any future PT reports as all other
values in that row would be null.
--
Regards

Roger Govier


wrote in message
oups.com...
Oooops, spoke too soon. The solution worked in the sense that it
produced a blank PivotTable without generating an error but it caused
a
problem with a date column in the PivotTable that's being grouped.

The PivotTable contains a date column that's grouped by Year and
Month.
Refreshing with a blank data source destroyed this grouping. My guess
is that this is because you cannot grouping a column with blank rows.

Any ideas?

Thanks,
Kris





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default PivotTable with No Source Data

Thanks again for the responses Roger - your suggestions were a big
help. The way I ended up solving the problem was to create two rows in
the source data that contained only the year and month and I used these
two columns in my pivot table rather than the original date column that
I was using. This approach allowed the PivotTable to automatically
group by year and month without having to define a custom grouping.

Sincerely,
Kris

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what types of source data can't be grouped in pivottable Group items in a PivotTable Excel Discussion (Misc queries) 0 September 2nd 09 10:31 AM
Dynamic PivotTable Data Source Lenardz Excel Discussion (Misc queries) 1 August 22nd 07 08:08 PM
Pivottable - use same source data, and group data differently Todd1 Excel Discussion (Misc queries) 1 May 14th 06 03:00 PM
Select different source data for a PivotTable chetoos Excel Worksheet Functions 1 September 8th 05 07:14 PM
How to source data from multiple worksheets in a PivotTable? Wally Excel Programming 2 December 9th 04 09:21 AM


All times are GMT +1. The time now is 09:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"