I have a PivotTable on worksheet (inventorySheet) and I want to copy the PivotTable data, which starts on cells P5 and Q5. I have a macro button I press on another worksheet (the sheet i want the data to be pasted on), but my code is copying data from the active worksheet instead of from inventorySheet.
I'm new to coding, but shouldn't my code Range("P5:Q5", Range("P5:Q5").End(xlDown)).Copy copy data from inventorySheet since it's within the With statement?
With inventorySheet
.PivotTables("inventoryPivot").ClearAllFilters
.PivotTables("inventoryPivot").PivotFields("Type"). _
CurrentPage = "REGIONAL"
Range("P5:Q5", Range("P5:Q5").End(xlDown)).Copy
End With
Thanks!
.Range("P5:Q5", .Range("P5:Q5").End(xlDown)).Copy
Without the.
it's not scoped to the With block – Tim Williams.
is needed in front of both ranges. Believe it's so it calls from the inventorySheet. Otherwise without the.
, even though it's within the With statement, it calls from the active sheet. Is this correct? – Automating_My_Life