Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default For Next Loop Chart Titles

The data is hard coded, not controlled by any variables. I can't tell what's
up with the title definition, it looks like it includes some counters, but
it also looks like bad syntax.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Jackie" wrote in message
...
Several people have helped me to get this far, and now I have the
following
code which works exactly as I need it to EXCEPT that it does not change
the
data or chart titles. I am VERY new to VB and can't figure out how to
write
the code to have the data update. The code produces 12 pages with four
charts to a page but they are all titled the same with the same data. Any
suggestions?


Sub correctchartmaker()
'
' correctchartmaker Macro
' Macro recorded 12/15/2006 by Jackie
'

'Declare Variables
Dim intLoopCount As Integer 'Counter for loop
Dim intRowStart As Integer 'Row number to start at for first chart
Dim intRowEnd As Integer 'Row number to end at for first chart
Dim intSheetChartCount As Integer 'Count of charts on a sheet
Dim intSheetCount As Integer 'Count of sheets
Dim strSheetName As String 'Name of sheet


'Initialize Variables
intLoopCount = 8 'Start in row 8 forloop
intRowStart = 8 'Start in row 8
intRowEnd = 9 'End in row 9
intSheetChartCount = 1 'First chart on sheet
intSheetCount = 1 'First sheet of charts


'Loop to create charts until no data is found
For intLoopCount = intRowStart To (Sheets(2).UsedRange.Rows.Count / 2) + 1


'Check if new sheet needs to be created
If intSheetChartCount = 1 Then

'Create a blank sheet
Worksheets.Add.Name = "Page" & intSheetCount

'Name Sheet
strSheetName = "Page" & intSheetCount

'Increment counter
intSheetCount = intSheetCount + 1

End If

'Create a blank chart
Charts.Add

'Format chart as Clustered Column
ActiveChart.ChartType = xlColumnClustered

'Set data source and data range
ActiveChart.SetSourceData Source:=Sheets("GradesExamscharts").Range( _
"F8:F9,H8:H9,J8:J9,L8:L9,N8:N9"), PlotBy:=xlRows
ActiveChart.SeriesCollection(1).XValues = _

"=(GradesExamscharts!R1C6,GradesExamscharts!R1C8,G radesExamscharts!R1C10,GradesExamscharts!R1C12,Gra desExamscharts!R1C14)"
ActiveChart.SeriesCollection(1).Name = "=GradesExamscharts!R8C4"
ActiveChart.SeriesCollection(2).XValues = _

"=(GradesExamscharts!R2C6,GradesExamscharts!R2C8,G radesExamscharts!R2C10,GradesExamscharts!R2C12,Gra desExamscharts!R2C14)"
ActiveChart.SeriesCollection(2).Name = "=GradesExamscharts!R9C4"
ActiveChart.Location Whe=xlLocationAsObject, Name:=strSheetName
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = 'GradesExamscharts'!R & intRowStart
C2:R & intRowStart C3:R
.ChartTitle.Select
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With


ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlLeft
ActiveChart.ChartArea.Select
Selection.AutoScaleFont = True

With Selection.Font
.Name = "Arial"
.Size = 7
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.ChartTitle.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
Selection.Font.Bold = True
ActiveChart.Axes(xlValue).Select

With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = 1
.MinorUnit = 0.04
.MajorUnit = 0.2
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

'Increment counters
intRowStart = intRowStart + 8
intRowEnd = intRowEnd + 8
intSheetChartCount = intSheetChartCount + 1

'Reset sheet chart counter to 1 if it goes beyond 4
If intSheetChartCount = 5 Then

intSheetChartCount = 1

End If

Next intLoopCount

End Sub





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
Chart Titles not showing in excel chart Greg_tnwre Excel Discussion (Misc queries) 1 July 28th 06 05:36 PM
Chart Titles not showing in excel chart Window Greg_tnwre Excel Discussion (Misc queries) 0 July 15th 06 03:41 AM
Centering Axis and Chart Titles on chart saturnin02 Excel Discussion (Misc queries) 1 February 9th 05 09:28 AM
How do I loop through workbook and rename all chart titles? Backpaddler Excel Programming 1 January 23rd 04 11:04 PM
chart titles T.K Kullervo Excel Programming 0 July 21st 03 01:36 PM


All times are GMT +1. The time now is 08:09 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"