Automatic Copying of Cells to Another Cells with Macro

BobPierre

New Member
Joined
Jun 5, 2018
Messages
8
Hi Everyone,
I am having an issue with using Macro. In fact I had never used it before.
I am having something like this:
A B C D E F
50Km Dispatches 1am 2am 3am
WEST 64 173
EAST 36 203
NORTH 1 37

I want my Macro to be picking values from B2 to B4 and place it in D2 to D4 respectively anytime I update my data and refresh my Pivot table While the next time I update it, it will pick values from B2 to B4 and place it in E2 to E4, etc

I have been trying this but it is not working:

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
ActiveSheet.Range("c2:c4").Copy
Sheets("Distance Report").Range("IV1").End(xlToLeft).Offset(1, 1).PasteSpecial xlValues
Application.CutCopyMode = False


End Sub


The issue is that it only works once, it wont work for subsequent update
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
maybe change

Sheets("Distance Report").Range("IV1").End(xlToLeft).Offset(1, 1).PasteSpecial xlValues

to
Sheets("Distance Report").Range("IV2").End(xlToLeft).Offset(1, 1).PasteSpecial xlValues
 
Upvote 0
Thanks for your response @rpaulson.
I have tried it but when I clicked on refresh all, it pastes it twice instead of once, although this what I used:

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
ActiveSheet.Range("c2:c4").Copy
Sheets("Distance Report").Range("IV2").End(xlToLeft).Offset(0, 1).PasteSpecial xlValues
Application.CutCopyMode = False
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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