View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Geoff Geoff is offline
external usenet poster
 
Posts: 371
Default Using PivotSelect method to find the top of a range

Hi

I have the following code, which selects the range containing all the labels
of the row field "Combination" in the pivot table "Combinations". It then
sets the value of lngRowStart as the row number of the active cell - this
should be the top (i.e. first) of the labels in this range.

ActiveSheet.PivotTables("Combinations").PivotSelec t "Combination[All]",
xlLabelOnly
lngRowStart = ActiveCell.Row
Do While ActiveCell.Value < ""
lngRowEnd = ActiveCell.Row
ActiveCell.Offset(1, 0).Activate
Loop

The problem is that frequently the top of the range is not selected.
Sometimes the active cell is the bottom (i.e. last) of the labels in the
range, meaning that the lngRowStart is assigned the same value as lngRowEnd
(not ideal in the context of this macro).

Can anyone suggest either an alternative way to get the top and bottom row
numbers of this range, or an alternative argument for the PivotSelect method
to specify that the top cell has to be active in the selection?

Thanks

--
There are 10 types of people in the world - those who understand binary and
those who don't.