VBABeginner1996
New Member
- Joined
- Sep 14, 2018
- Messages
- 5
Hi everyone,
I have been learning VBA over the past couple of months and have come up with a problem. I have been trying to write code that will paste Selected charts in one sheet and paste them to another. I have multiple charts on one sheet but only want to paste a few of them to another. To do this i have written the code below.
Whilst the number of charts pasted is always correct no matter which charts i select the ones that are pasted do not depend on the selection but the order of the chart creation. So, if I had 3 charts and selected charts 2 and 3 and ran the code, charts 1 and 2 would be pasted instead. If anyone help it would be much appreciated.
I have been learning VBA over the past couple of months and have come up with a problem. I have been trying to write code that will paste Selected charts in one sheet and paste them to another. I have multiple charts on one sheet but only want to paste a few of them to another. To do this i have written the code below.
Code:
Sub copyandpaste()
Dim i As Integer
For i = 1 To Selection.Count
Selection(i).Copy
ActiveWorkbook.Worksheets("Sheet2").Paste
Next i
End Sub
Whilst the number of charts pasted is always correct no matter which charts i select the ones that are pasted do not depend on the selection but the order of the chart creation. So, if I had 3 charts and selected charts 2 and 3 and ran the code, charts 1 and 2 would be pasted instead. If anyone help it would be much appreciated.