teatimecrumpet
Active Member
- Joined
- Jun 23, 2010
- Messages
- 307
Hi,
I've used some code with the macro recorder to hide certain elements of a particular row field. But when trying to use it on a similar set of data it will return a 400 error when it tries to hide a field that is not there.
Is there a way to change the code so it will hide if it IS there but ignore trying to hide it if it IS NOT there and continue to hide the others?
here is the code:
With ActiveSheet.PivotTables("TD").PivotFields( _
"code")
.PivotItems("DL").Visible = False
.PivotItems("FD").Visible = False
.PivotItems("NF").Visible = False
.PivotItems("NP").Visible = False
.PivotItems("PE").Visible = False
.PivotItems("PR").Visible = False
.PivotItems("SC").Visible = False
.PivotItems("TC").Visible = False
.PivotItems("(blank)").Visible = False
End With
it'll crash or return the 400 error when it tries to hide "NF" which I've highlighted red above.
Thanks in advance,
Mike
I've used some code with the macro recorder to hide certain elements of a particular row field. But when trying to use it on a similar set of data it will return a 400 error when it tries to hide a field that is not there.
Is there a way to change the code so it will hide if it IS there but ignore trying to hide it if it IS NOT there and continue to hide the others?
here is the code:
With ActiveSheet.PivotTables("TD").PivotFields( _
"code")
.PivotItems("DL").Visible = False
.PivotItems("FD").Visible = False
.PivotItems("NF").Visible = False
.PivotItems("NP").Visible = False
.PivotItems("PE").Visible = False
.PivotItems("PR").Visible = False
.PivotItems("SC").Visible = False
.PivotItems("TC").Visible = False
.PivotItems("(blank)").Visible = False
End With
it'll crash or return the 400 error when it tries to hide "NF" which I've highlighted red above.
Thanks in advance,
Mike