Question : VBA for Multiple Chart Creation using SheetsFound

Hi, I need some expert advice.

I currently have made a spreadsheet in which i input some data from an external report; a macro is then run to analyse the data and it transfers anything which doesnt meet a set criteria to Sheet2 & sorts in order.
The macro then creates tabs for each of the different client names listed within sheet1, in date order (as the report actually shows targets over a month).

I'm stuck now as I would like a macro which would automatically create scatter graphs within each of the tabs showing the performance of the client over the month - I can't seem to do this with anything but the active sheet - and the macro has to work on the basis it will not know how many sheets (so it'll have to loop) or the names of these sheets (meaning it's going to have to complete a sheetfound).

I've attached an example of how the sheet would look once the macro had run to the point of where I am now.

Any help would be greatly appreciated.
 
 
 
 
 
 

Answer : VBA for Multiple Chart Creation using SheetsFound

Ok, I took your sheet1 value from your attached workbook and put it in a new workbook.  I then copied your code and ran it.  It ran successfully with a "Done" msgbox.  It created Client1 Client2 and Client3 sheets with data.  However, none of these sheets have values in the D Column.

I then ran my sub below.  It placed charts on each Client worksheet using the A2:A32,D2:D32 as the datasource on each.

Maybe I'm misunderstanding....

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Sub charts()
Dim sht As Worksheet
Dim wb As Workbook
  
Set wb = ActiveWorkbook
For Each sht In wb.Sheets
    If InStr(1, sht.Name, "Client") > 0 Then
        With sht.ChartObjects.Add(Left:=100, Width:=375, Top:=75, Height:=225)
            .Chart.SetSourceData Source:=sht.Range("A2:A32,D2:D32")
            .Chart.ChartType = xlXYScatter
        End With
    End If
Next
End Sub
Random Solutions  
 
programming4us programming4us