Creating Multiple Charts

Ian Mangelsdorf

New Member
Joined
Dec 4, 2003
Messages
2
Hi all

Ive got a sheet with a block of data that need to be plotted

What I would like to do is create a new chartsheet for each sample is there some simple code that can loop through all smples and add a chart sheet for each?

Something along the lines of

For each sample in group

create chart sheet

etc

any help would be great

Cheers

Ian
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
The data is laid out as follows

The stable Y axis is in cells b5:i5

The variable x axis for each samples is in cells b6:i6 b7:i7 etc etc

there is no limit to the number of samples but usually sits around 20.


short of posting a workbook this is as good as I get

Cheers

Ian
 
Upvote 0
Turn on the macro recorder and create one chart the way you want. Share that code (format it for readability: paste the code into the textbox used for posting to this forum, select the posted code, and click the 'Code' button at the top of the form), and someone should be able to show you how to automate it for a generic range and a generic number of data sets.
Ian Mangelsdorf said:
{snip}


short of posting a workbook this is as good as I get

Cheers

Ian
 
Upvote 0
Here's a starter:

Code:
Sub Test()
    Dim Sh As Worksheet
    Dim Rng As Range
    Dim ChtRng As Range
    Dim x As Integer
    Set Sh = Worksheets("Sheet1")
    Set Rng = Sh.Range("B6:I" & Sh.Range("B6").End(xlDown).Row)
    For x = 1 To Rng.Rows.Count
        Set ChtRng = Range(Rng.Cells(x, 1), Rng.Cells(x, 8))
        Set ChtRng = Union(Sh.Range("B5:I5"), ChtRng)
        Charts.Add
        ActiveChart.ChartType = xlXYScatterLinesNoMarkers
        ActiveChart.SetSourceData Source:=ChtRng
        ActiveChart.Location Where:=xlLocationAsNewSheet
    Next x
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,484
Messages
6,130,936
Members
449,608
Latest member
jacobmudombe

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