Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Specify pivot table to hide 'earlier than' grouped data start date

I have been making some good progress with creating charts summarising data
by use of pivot table and charts. These are generated from the raw data by a
macro that can be applied to many input data sets.

One problem I have not overcome relates to grouping of data so that I show
whole weeks, counting back from the date of lastest data. I can show a given
number of weeks by specifying the start date, but I cannot find the VBA code
that suppresses the data that is 'earlier than' the start date. If I was
driving the table manually, I would select the field drop down and deactivate
the '<01/01/2000' group. My code is shown below and the point of failure is
in the second last line where ("<" & Str(BVGrpStart)) was an attempt to
derive a text value based on the variable which contains the earliest date
that I want to show. When the brackets enclose a text string like
"<01/01/2000" it would work, but I need to drive the text from my date
variable.

I would be grateful for any help that can be offered - I have not been able
to find it in the usual VBA help files.

' group BV dates to start complete number of weeks prior to last BV end
date
Dim lastBVend, BVGrpStart As Date
lastBVend = Range("Customer_view!B1").Value
'show a maximum of 20 weeks data - 140 days
BVGrpStart = lastBVend - 139
Range("A6").Select
Selection.Group Start:=BVGrpStart, End:=True, By:=7,
Periods:=Array(False, False, False, True, False, False, False)

With ActiveSheet.PivotTables("PerfSummary").PivotFields ("end date of BV
data")
.PivotItems("<" & Str(BVGrpStart)).Visible = False
End With

--
KenY
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Specify pivot table to hide 'earlier than' grouped data start date

Try this,

With ActiveSheet.PivotTables("PerfSummary").PivotFields ("end date of BV
data")

'to hide first date starting with "<"
If Left(.PivotItems(1), 1) = "<" Then .PivotItems(1).Visible = False

'to hide last date starting with ""
If Left(.PivotItems(.PivotItems.Count), 1) = "" Then
..PivotItems(.PivotItems.Count).Visible = False

End With

or

use Dateserial function with your variable named BVGrpStart.


Regards,
Shah Shailesh
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)

*** Sent via Developersdex http://www.developersdex.com ***
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Specify pivot table to hide 'earlier than' grouped data start

Thanks - I used your first method and it works a treat

--
KenY


"Shailesh Shah" wrote:

Try this,

With ActiveSheet.PivotTables("PerfSummary").PivotFields ("end date of BV
data")

'to hide first date starting with "<"
If Left(.PivotItems(1), 1) = "<" Then .PivotItems(1).Visible = False

'to hide last date starting with ""
If Left(.PivotItems(.PivotItems.Count), 1) = "" Then
.PivotItems(.PivotItems.Count).Visible = False

End With

or

use Dateserial function with your variable named BVGrpStart.


Regards,
Shah Shailesh
http://in.geocities.com/shahshaileshs/
(Excel Add-ins Page)

*** Sent via Developersdex http://www.developersdex.com ***

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
I want to hide data that's less than 1 in a pivot table SDixon578 Excel Discussion (Misc queries) 0 April 23rd 08 01:09 PM
how to show repeating data in pivot table (not grouped) NKA Excel Discussion (Misc queries) 2 April 15th 08 12:54 AM
Format a Grouped Date in a Pivot Table lsantos13 Excel Worksheet Functions 2 March 14th 07 04:06 PM
Pivot Table - hide if no data SusanJane sjl Excel Discussion (Misc queries) 2 September 16th 06 01:19 AM
how to change date formating-grouped by month in pivot table Yahýa Excel Discussion (Misc queries) 4 June 24th 06 09:15 AM


All times are GMT +1. The time now is 12:14 AM.

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

About Us

"It's about Microsoft Excel"