get the value of the cell selected error

D

Diego

Hi!
i have the next code:

Set oDetCell = oSel.BottomRight
lRowNum = oDetCell.Row
lColNum = oDetCell.Column
With PivotTable1.ActiveData
Set oCell = .Cells(.RowMembers(0), .ColumnMembers(0))
End With
oCellValue = oCell.DetailCells(lRowNum, lColNum)

i'm trying to get the value of the cell selected by the
user, but this code generate me an error that says
Subscript out of range .
Does anybody knows how to fix it?

thanks
 
D

Dan Ricker

I'm a little confused here.

The First Statement:
''' Assuming oSel = PivotTable.Selection
Set oDetCell = oSel.BottomRight
Actually gets "a PivotDetailCell". oDetCell.Value will
give the value of that PivotDetailCell.

The rest of the code seem to attempt to walk up the OM
just to return back to the same PivotDetailCell that was
originally selected???

Anyway...



Set oSel = PivotTable.Selection
Set oDetCell = oSel.BottomRight ''' (or TopLeft for single
cell selection)
lRowNum = oDetCell.Row
lColNum = oDetCell.Column

With PivotTabel.ActiveData
Set oCell = .Cells(oDetCell.Cell.RowMember,
oDetCell.Cell.ColumnMember)
End With
''' or just
''' Set oCell = oDetCell.Cell


oCellValue = oCell.DetailCells(lRowNum, lColNum).Value
''' or just
''' oCellValue = oDetCell.Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top