Ramballah
Active Member
- Joined
- Sep 25, 2018
- Messages
- 332
- Office Version
- 365
- Platform
- Windows
Hello i have a question
I have this code i wrote for copying my charts to save the information once im done with. heres the code:
As you can see it does its job i want him to do. However i need more than 50 charts and this only covers the first 2 basically... Is there a way that VBA automatically adds up the amount of cells he needs to go to the right / down to paste the next chart? So i dont need to write this code 48 more times?? if im not clear enough just ask im willing to drop my file for download.
I have this code i wrote for copying my charts to save the information once im done with. heres the code:
Code:
Sub Range_Copy_Example() Dim First_Chart As String, Second_Chart As String, Third_Chart As String
Dim Fourth_Chart As String
First_Chart = Range("B2")
Second_Chart = Range("K2")
Third_Chart = Range("T2")
Fourth_Chart = Range("B104")
'This copies a cellrange and removes it.
If First_Chart = "" = False And Second_Chart = "" = True Then
Range("A1:H101").Copy Range("J1:Q101")
Range("B2:D101").ClearContents
Range("F2:H101").ClearContents
ElseIf First_Chart = "" = False And Third_Chart = "" = True Then
Range("A1:H101").Copy Range("S1:Z101")
Range("B2:D101").ClearContents
Range("F2:H101").ClearContents
End If
End Sub