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

I am trying to retrieve the cell which contains the pivotitem. I am trying to
do this using datarange. But everytime i try to the run the following code,
it gives an "Application defined or Object defined error" .

I tried debugging and it states that the application is unable to find the
datarange. No idea why this happens. Is there a way around this to find the
range.



Code

Function returnIL5Cell(ByVal plitem As PivotField) As Range

Dim rng As Range
Dim pl As PivotItem

Set pl = plitem.PivotItems(2)
rng = pl.DataRange.select

response = MsgBox(rng.Value, vbOKCancel)

End Function


thanks & regards,

Nikhil.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Retrieve pivotitem range

My guess would be you want either something like
Set rng = pl.DataRange
rng.Select
or
pl.DataRange.Select
Set rng = ActiveSheet.Selection

but I'm pretty sure you can't make a range assignment and select it in the
same breath.

I've read that "Set" has become unnecessary in XL2007, but if you aren't
using that version it's mandatory when assigning an object variable like
rng.

HTH,


"bowka" wrote in message
...
I am trying to retrieve the cell which contains the pivotitem. I am trying
to
do this using datarange. But everytime i try to the run the following
code,
it gives an "Application defined or Object defined error" .

I tried debugging and it states that the application is unable to find the
datarange. No idea why this happens. Is there a way around this to find
the
range.



Code

Function returnIL5Cell(ByVal plitem As PivotField) As Range

Dim rng As Range
Dim pl As PivotItem

Set pl = plitem.PivotItems(2)
rng = pl.DataRange.select

response = MsgBox(rng.Value, vbOKCancel)

End Function


thanks & regards,

Nikhil.



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
Retrieve last non zero value in a range of cells Pete[_5_] New Users to Excel 2 June 10th 11 08:57 PM
How to retrieve Named Range name? Guntars Excel Worksheet Functions 3 June 8th 09 03:06 AM
Retrieve value from a range of cells EMoe Excel Worksheet Functions 3 June 19th 06 07:02 PM
Retrieve individual cells from a range changed between a range baldomero[_4_] Excel Programming 3 September 5th 05 07:31 PM
How to retrieve range in formula? deko Excel Programming 10 January 14th 05 07:22 PM


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