Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Event handler


Hi,

Looking for excel to activate a macro when a user double clicks on a
pivot table to drill down into what makes up the total. Think I need
something like the beliow to call my macro called FillColours.

Does anyone have any thoughts ??


VBA:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target As Range, _
Cancel As Boolean)


If ActiveSheet.PivotTables.EnableDrilldown = True Then Call
FillColours

End Sub

Thanks
VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=536327

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Event handler

Yes, you are on the right track except the code as you have it would run for
any double click on the sheet, whether on the pivottable or no. To make it
run only if the user double-clicks on the PivotTable, first it would be
easier to put the code in the Worksheet_BeforeDoubleClick event so you
already are sure you are on the right sheet, then check to see if the cell is
in the pivottable range - you do that by using the Intersect method to see if
the Target range intersects (is part of) the pivottable's range which is
either the TableRange1 or TableRange2 property (depends on if you want to
include the field names). Also, one note: you can always replace IF A=True
THEN by IF A THEN; it simplifies the code a bit:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)

If ActiveSheet.PivotTables.EnableDrilldown and _
Not(Intersect(Target, ActiveSheet.PivotTables(1).TableRange2) Is
Nothing) _
Then Call FillColours

End Sub


--
- K Dales


"VBA Noob" wrote:


Hi,

Looking for excel to activate a macro when a user double clicks on a
pivot table to drill down into what makes up the total. Think I need
something like the beliow to call my macro called FillColours.

Does anyone have any thoughts ??


VBA:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target As Range, _
Cancel As Boolean)


If ActiveSheet.PivotTables.EnableDrilldown = True Then Call
FillColours

End Sub

Thanks
VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=536327


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Event handler


Hi K Dale,

Thanks for this code however I get a error message for Is nothing.

Thanks

Danny

K Dales Wrote:
Yes, you are on the right track except the code as you have it would ru
for
any double click on the sheet, whether on the pivottable or no. T
make it
run only if the user double-clicks on the PivotTable, first it woul
be
easier to put the code in the Worksheet_BeforeDoubleClick event so you
already are sure you are on the right sheet, then check to see if th
cell is
in the pivottable range - you do that by using the Intersect method t
see if
the Target range intersects (is part of) the pivottable's range whic
is
either the TableRange1 or TableRange2 property (depends on if you wan
to
include the field names). Also, one note: you can always replace I
A=True
THEN by IF A THEN; it simplifies the code a bit:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)

If ActiveSheet.PivotTables.EnableDrilldown and _
Not(Intersect(Target, ActiveSheet.PivotTables(1).TableRange2) Is
Nothing) _
Then Call FillColours

End Sub


--
- K Dales


"VBA Noob" wrote:


Hi,

Looking for excel to activate a macro when a user double clicks on a
pivot table to drill down into what makes up the total. Think I need
something like the beliow to call my macro called FillColours.

Does anyone have any thoughts ??


VBA:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object

ByVal
Target As Range, _
Cancel As Boolean)


If ActiveSheet.PivotTables.EnableDrilldown = True Then Call
FillColours

End Sub

Thanks
VBA Noob


--
VBA Noob


------------------------------------------------------------------------
VBA Noob's Profile

http://www.excelforum.com/member.php...o&userid=33833
View this thread

http://www.excelforum.com/showthread...hreadid=536327



--
VBA Noo
-----------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...fo&userid=3383
View this thread: http://www.excelforum.com/showthread.php?threadid=53632

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Event handler

Just as I said before, this will give you an error:

ActiveSheet.PivotTables.EnableDrilldown

but

? activesheet.PivotTables(1).enabledrilldown
True

works fine as you can see.

--
Regards,
Tom Ogilvy




"VBA Noob" wrote:


Hi K Dale,

Thanks for this code however I get a error message for Is nothing.

Thanks

Danny

K Dales Wrote:
Yes, you are on the right track except the code as you have it would run
for
any double click on the sheet, whether on the pivottable or no. To
make it
run only if the user double-clicks on the PivotTable, first it would
be
easier to put the code in the Worksheet_BeforeDoubleClick event so you
already are sure you are on the right sheet, then check to see if the
cell is
in the pivottable range - you do that by using the Intersect method to
see if
the Target range intersects (is part of) the pivottable's range which
is
either the TableRange1 or TableRange2 property (depends on if you want
to
include the field names). Also, one note: you can always replace IF
A=True
THEN by IF A THEN; it simplifies the code a bit:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)

If ActiveSheet.PivotTables.EnableDrilldown and _
Not(Intersect(Target, ActiveSheet.PivotTables(1).TableRange2) Is
Nothing) _
Then Call FillColours

End Sub


--
- K Dales


"VBA Noob" wrote:


Hi,

Looking for excel to activate a macro when a user double clicks on a
pivot table to drill down into what makes up the total. Think I need
something like the beliow to call my macro called FillColours.

Does anyone have any thoughts ??


VBA:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object,

ByVal
Target As Range, _
Cancel As Boolean)


If ActiveSheet.PivotTables.EnableDrilldown = True Then Call
FillColours

End Sub

Thanks
VBA Noob


--
VBA Noob

------------------------------------------------------------------------
VBA Noob's Profile:

http://www.excelforum.com/member.php...o&userid=33833
View this thread:

http://www.excelforum.com/showthread...hreadid=536327




--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=536327


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Event handler

Enabledrilldown is a property of an individual pivot table, so you can't use
it with the pivottables collection as you show. You would probably first
want to check if the Target is within a range that would drilldown. then
check for that pivot table if the enable drilldown property is enabled.

--
Regards,
Tom Ogilvy


"VBA Noob" wrote:


Hi,

Looking for excel to activate a macro when a user double clicks on a
pivot table to drill down into what makes up the total. Think I need
something like the beliow to call my macro called FillColours.

Does anyone have any thoughts ??


VBA:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal
Target As Range, _
Cancel As Boolean)


If ActiveSheet.PivotTables.EnableDrilldown = True Then Call
FillColours

End Sub

Thanks
VBA Noob


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=536327




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
Clipboard Event Handler? [email protected] Excel Programming 1 April 2nd 06 04:37 AM
Autoshape event handler? [email protected] Excel Programming 7 February 23rd 06 10:12 PM
Event handler is invalid Minh[_2_] Excel Programming 2 December 8th 05 02:00 AM
Global event handler?? [email protected] Excel Programming 1 October 23rd 04 05:31 PM
Cell Event Handler David Excel Programming 3 January 19th 04 04:51 PM


All times are GMT +1. The time now is 03:00 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"