PDA

View Full Version : error when changing data in a Pivot table usinga macro



venkiatmarut
11-26-2009, 09:26 AM
Hi,

Please help me out from this problem. I didn't understand what is wrong with my code.

I have an excel pivot table and I used macro to change the data into it. It is going and when it is changing the data it is showing the error as_



Run-time error '1004':
Cannot change this part of a Pivot Table report.


The code is as follows___



Dim s_value As String
'LOOP THROUGH ALL SELECTED CELLS AND FILL THE EMPTY CELLS WITH VALUE IN THE PRIOR NON EMPTY CELL
For Each c In ActiveWindow.RangeSelection.Cells
c.Select
If Len(c.Value) > 0 Then
s_value = c.Value
Else
c.NumberFormat = "@"
c.Value = CStr(s_value)
End If
Next c
s_value = ""


Please help me out.

JWhite
11-27-2009, 07:28 AM
You can't change a cell in a pivottable, whether you're doing it manually or with code. A pivottable is a read-only report based on whatever the source data is. You have to change the source data if you want the pivottable to change.

venkiatmarut
11-27-2009, 11:51 PM
You can't change a cell in a pivottable, whether you're doing it manually or with code. A pivottable is a read-only report based on whatever the source data is. You have to change the source data if you want the pivottable to change.

Thanks for your reply Jwhite.

Changing the source data is not possible. We are grouping the data in a specific format.
I got the solution for this problem. We have to copy the table and paste it on other sheet using PASTESPECIAL-> VALUES option. Then we can modity/change the rows or columns.

Thanks a lot for your reply.