Copy Chart and paste as picture using a distinct list values

alex_shin

New Member
Joined
Apr 16, 2014
Messages
1
Hi All,

I am trying to get the script to copy the chart and paste as picture using data from a list (offset List until empty cell).

The VBA below ran successfully but did not do the 1st FOR LOOP that I wanted it to.

Code:
[COLOR=#333333]Sub xxx()[/COLOR]

[COLOR=#333333]'[/COLOR]
[COLOR=#333333]' Prevents Screen Refreshing[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = False[/COLOR]

[COLOR=#333333]Range("B6").Select[/COLOR]
[COLOR=#333333]Application.CutCopyMode = False[/COLOR]
[COLOR=#333333]ActiveCell.FormulaR1C1 = _[/COLOR]
[COLOR=#333333]"=IF(R2C2="""","""",SUMIFS(Sheet1!C[1],Sheet1!C1,R2C2,Sheet1!C2,RC1))"[/COLOR]

'Create 1st Loop by using the
Dim x As Integer


    'Set Numrows = number of rows of data
    numrows = Range("I2", Range("H:H").End(xlDown)).Rows.Count
    
    ' Select cell B2
    Range("B2").Select
    
    ' Establish "For" loop to loop "numrows" number of times
    For x = 1 To numrows
    
    ActiveCell.FormulaR1C1 = "=RC[7]"


        Dim arange As Range


            Range("A5:F29").Select
            Application.CutCopyMode = False
            Selection.Copy
            Range("A38").Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
               :=False, Transpose:=False
            Set arange = Range("A38:F62")
                    
                    For Each cell In arange
                        If cell.Text = "#N/A" Then
                           cell.ClearContents
                        End If
    
                    Next


        ActiveSheet.ChartObjects("Chart 1").Activate
        Application.CutCopyMode = False
        ActiveChart.ChartArea.Copy
        Range("K65").Select
        ActiveSheet.PasteSpecial Format:="Picture (JPEG)", Link:=False, _
        DisplayAsIcon:=False


    Next

[COLOR=#333333]End Sub[/COLOR]
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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