maraippo 0 Newbie Poster

Hello..

I want to make a macro to create a chart from a table in different sheet. What i try to do is copy the information into a new sheet. Next i use the information copied to make a column clustered chart. The problem is the chart does not appead in the sheet it created.

Say, i copy the info from sheet3 to "chart1" sheet. Then i want to place the chart created to "chart1", but what happen is the chart appear in the 1st sheet of the workbook...

This is the code i've taken and modified:

Private Sub makechart()

    
Dim work_book As Workbook
Dim last_sheet As Worksheet
Dim new_sheet As Worksheet


    ' Make a new worksheet.
    
    Sheets("sheet3").Select
    Range("C4:J4,C6:J6").Select
    Selection.Copy

    ' Make a new worksheet.
    With ThisWorkbook
    Set work_book = Application.ActiveWorkbook
    Set last_sheet = _
        work_book.Sheets(work_book.Sheets.Count)
    Set work_book = Application.ActiveWorkbook
    Set new_sheet = work_book.Sheets.Add(after:=last_sheet)
    new_sheet.name = "bin#"
    ActiveSheet.Paste
    
     End With
    
    Range("A1:H2").Select
    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=Sheets("bin#").Range("A1:H2"), PlotBy:= _
        xlRows
    ActiveChart.Location Where:=xlLocationAsObject, name:="bin#"
    With ActiveChart
        .HasTitle = False
        .Axes(xlCategory, xlPrimary).HasTitle = False
        .Axes(xlValue, xlPrimary).HasTitle = False
    End With
    
End Sub

Can anyone help me to change it so that i can make the chart for every row in the specified table-each in different sheet named watever.

Total number of row is 36, means that there will be another 36 sheets added in the workbook

I hope the chart will appear in the same sheet i copy the range like above.

Thank you in advance for those helping :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.