LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
deb deb is offline
external usenet poster
 
Posts: 2
Default Excel macro to loop through worksheets and graph data from each worksheet

I am trying to create an excel macro that will loop through 22
worksheets in a workbook and create an graph with data from each
worksheet. These data are located in the same positions in each
worksheet, however, the range of data varies across worksheets. I
found a code to loop through worksheets. How do I code a macro that
produces a graph based on each active worksheet and current region of
cells in each worksheet as it loops through the worksheets? Any
ideas???? I have never coded in VB before and do not have a lot of
experience with coding excel macros. I posted my novice code here so
that someone who has more experience with VB or excel macro may,
hopefully, get a better idea of what I am trying to do.




Sub WorksheetLoop()

Dim WS_Count As Integer
Dim I As Integer

' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count

' Begin the loop.
For I = 1 To WS_Count
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData
Source:=ActiveWorkbook.Worksheets(I).Range("A1").C urrentRegion,
PlotBy:=
xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Marker"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "LOD
Score"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasDataTable = False
' The following line shows how to reference a sheet within
' the loop by displaying the worksheet name in a dialog box.
MsgBox ActiveWorkbook.Worksheets(I).Name

Next I

End Sub
 
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
Macro/Method of Importing DATA in a loop Faraz A. Qureshi Excel Discussion (Misc queries) 2 August 5th 09 07:34 AM
How to Loop a macro in Excel flecky New Users to Excel 4 June 12th 07 02:10 PM
How can I setup an Excel Macro to loop? ExcelNovice Excel Discussion (Misc queries) 3 March 28th 06 10:12 PM
Excel Macro loop problems mibsaweiss Excel Discussion (Misc queries) 0 March 16th 06 04:45 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM


All times are GMT +1. The time now is 06:03 PM.

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

About Us

"It's about Microsoft Excel"