Copy Pivot table to another sheet and delete all (blanks) values from the cells

Romano_odK

Active Member
Joined
Jun 4, 2020
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

I got some code and I am trying to delete all the "(blank)" that came with copying of the Pivot table. At the moment I get an error, but when I fill in anothe value, like a number it works. So why can't I delete the (blank) values?

Thank you ffor your time

Romano


Private Sub CommandButton1_Click()
Dim ws As Worksheet


Set ws = Worksheets.Add
ActiveSheet.Name = "Production"
Sheets("Prijslijst").Select
ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel, True
Selection.copy

ws.Range("A1").PasteSpecial Paste:=xlPasteValues
ws.Range("A1").PasteSpecial Paste:=xlPasteFormats
ws.Range("A1").PasteSpecial Paste:=xlPasteColumnWidths

Sheets("Production").Select
Dim xCel As Range
Set xRange = Range("A:Q")
For Each xCel In xRange
If xCel.Value = "(blank)" Then
xCel.Offset(, 3).ClearContents
End If
Next xCel


End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,213,560
Messages
6,114,309
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top