Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Multiple graphs

Hi there. I want to create a graph for the title row and then each row
in turn of a spreadsheet, choosing the next rwo down each time.
Trouble is there are 150 rows and I want to write a macro to do it for
me. I have tried with a modicum of success. I can create a graph for
each row in a new chart and rename it, but it produces the same graph
each time, as I cannot get the "RowSource" control to accept a
variable. This is my code:
Sub Create_Graph()
'
' Create_Graph Macro

Dim Nextrow As Integer
Dim Titlerow As Range
Dim j As Range
Dim k As Range
Dim l As Range
Dim m As Range
Dim n As Range
Dim o As Range
Dim p As Range
Dim q As Range
Dim r As Range
Dim s As Range
Dim t As Range
Dim u As Range

For Nextrow = 2 To 5

Set j = Worksheets("All Year").Range("J" & Nextrow)
Set k = Worksheets("All Year").Range("K" & Nextrow)
Set l = Worksheets("All Year").Range("L" & Nextrow)
Set m = Worksheets("All Year").Range("M" & Nextrow)
Set n = Worksheets("All Year").Range("N" & Nextrow)
Set o = Worksheets("All Year").Range("O" & Nextrow)
Set p = Worksheets("All Year").Range("P" & Nextrow)
Set q = Worksheets("All Year").Range("Q" & Nextrow)
Set r = Worksheets("All Year").Range("R" & Nextrow)
Set s = Worksheets("All Year").Range("S" & Nextrow)
Set t = Worksheets("All Year").Range("T" & Nextrow)
Set u = Worksheets("All Year").Range("U" & Nextrow)

Set Titlerow = Worksheets("All Year").Range("J1:U1")
Set myMultipleRange = Union(Titlerow, j, k, l, m, n, o, p, q, r,
s, t, u)


Worksheets("All Year").Select
myMultipleRange.Select
j.Activate

Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("All
Year").Range(myMultipleRange), PlotBy _
:=xlRows
ActiveChart.Location Whe=xlLocationAsNewSheet
ActiveSheet.Name = "Fred"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Fred"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.Legend.Select
Selection.Delete

Sheets("All Year").Select
Forename = Range("G" & Nextrow).Text
Surname = Range("H" & Nextrow).Text

Sheets("Fred").Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = Forename & " " & Surname
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveSheet.Name = Forename & " " & Surname
Sheets("All Year").Select
Next Nextrow
End Sub

Can anybody help me?

Regards

Don

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Multiple graphs

on the .range use soething like this to get your offsets

..Range("A1").Offset(RowOffset:=Nextrow, columnoffset:=0)


Note: Nextrow is an offset from the Range "A1"



"Don" wrote:

Hi there. I want to create a graph for the title row and then each row
in turn of a spreadsheet, choosing the next rwo down each time.
Trouble is there are 150 rows and I want to write a macro to do it for
me. I have tried with a modicum of success. I can create a graph for
each row in a new chart and rename it, but it produces the same graph
each time, as I cannot get the "RowSource" control to accept a
variable. This is my code:
Sub Create_Graph()
'
' Create_Graph Macro

Dim Nextrow As Integer
Dim Titlerow As Range
Dim j As Range
Dim k As Range
Dim l As Range
Dim m As Range
Dim n As Range
Dim o As Range
Dim p As Range
Dim q As Range
Dim r As Range
Dim s As Range
Dim t As Range
Dim u As Range

For Nextrow = 2 To 5

Set j = Worksheets("All Year").Range("J" & Nextrow)
Set k = Worksheets("All Year").Range("K" & Nextrow)
Set l = Worksheets("All Year").Range("L" & Nextrow)
Set m = Worksheets("All Year").Range("M" & Nextrow)
Set n = Worksheets("All Year").Range("N" & Nextrow)
Set o = Worksheets("All Year").Range("O" & Nextrow)
Set p = Worksheets("All Year").Range("P" & Nextrow)
Set q = Worksheets("All Year").Range("Q" & Nextrow)
Set r = Worksheets("All Year").Range("R" & Nextrow)
Set s = Worksheets("All Year").Range("S" & Nextrow)
Set t = Worksheets("All Year").Range("T" & Nextrow)
Set u = Worksheets("All Year").Range("U" & Nextrow)

Set Titlerow = Worksheets("All Year").Range("J1:U1")
Set myMultipleRange = Union(Titlerow, j, k, l, m, n, o, p, q, r,
s, t, u)


Worksheets("All Year").Select
myMultipleRange.Select
j.Activate

Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("All
Year").Range(myMultipleRange), PlotBy _
:=xlRows
ActiveChart.Location Whe=xlLocationAsNewSheet
ActiveSheet.Name = "Fred"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Fred"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.Legend.Select
Selection.Delete

Sheets("All Year").Select
Forename = Range("G" & Nextrow).Text
Surname = Range("H" & Nextrow).Text

Sheets("Fred").Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = Forename & " " & Surname
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveSheet.Name = Forename & " " & Surname
Sheets("All Year").Select
Next Nextrow
End Sub

Can anybody help me?

Regards

Don


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
graphs with multiple variations q.m. hollemans Excel Discussion (Misc queries) 0 July 10th 07 01:20 PM
Updating multiple graphs in multiple worksheets at the same time J@Y Excel Discussion (Misc queries) 3 February 1st 07 03:30 AM
Aligning multiple graphs F*SH Charts and Charting in Excel 5 July 18th 06 09:51 AM
Multiple Graphs - Resize All James Hamilton Excel Discussion (Misc queries) 2 April 20th 06 12:50 AM
Multiple Graphs Ross Excel Discussion (Misc queries) 2 November 23rd 05 05:32 PM


All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"