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

Hello,

I have got a little problem with a macro, that is intended to create charts
on every sheet of a workbook. The macro runs and creates all the charts, but
on the sheet that was active when the macro was started. I.e. there are 17
sheets in a workbook, then there are 17 charts on the first sheet after the
macro was running. I really donīt know where the bug is. By the way, I am
not very familiar with macros and I am working with Excel 2000.

Another goody for the macro would be to select a range on each sheet, and
the macro recognizes these individual ranges for the chart creation.
Probably there must be a change in the code in this line:

"ActiveChart.SetSourceData Source:=Sheets(vSheet).Range("C12:X145"),
PlotBy:=xlColumns"

but I really donīt know how this should look like.

Please help me.

Following the macro, as it looks currently:


----------------------------------------------------------------------------
---
Sub ChartMakro()

Dim vSheet As String

Num_Sheets = Sheets.Count 'Determine the number of sheets in
the workbook

For x = 1 To Sheets.Count 'Loop through all sheets,
beginning with Sheet 2
Sheets(x).Activate 'Activate the sheet

vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(vSheet).Range("C12:X145"),
PlotBy:=xlColumns
Sheets(x).Activate
ActiveChart.Location Whe=xlLocationAsObject, Name:=ActiveSheet.Name

With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Name

End With


Next x 'Loop to next sheet

End Sub
----------------------------------------------------------------------------
--------------


Probably my posting does not contain my realname in the "send by" -column. I
donīt know how to change this in Outlook 2000.

Juergen Schweizer


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Macro for multiple charts

Try this out.

Sub ChartMakro()

Dim vSheet As String

Num_Sheets = Sheets.Count 'Determine the
number of sheets inthe Workbook

For x = 1 To Sheets.Count 'Loop through
all sheets,beginning with Sheet 2
Sheets
(x).Activate 'Activate the
sheet

vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(vSheet).Range
("C12:X145"), PlotBy _
:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:=Sheets(vSheet).Name

With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Name

End With


Next
x 'Loop
to next sheet

End Sub
-----Original Message-----
Hello,

I have got a little problem with a macro, that is

intended to create charts
on every sheet of a workbook. The macro runs and creates

all the charts, but
on the sheet that was active when the macro was started.

I.e. there are 17
sheets in a workbook, then there are 17 charts on the

first sheet after the
macro was running. I really donīt know where the bug is.

By the way, I am
not very familiar with macros and I am working with Excel

2000.

Another goody for the macro would be to select a range on

each sheet, and
the macro recognizes these individual ranges for the

chart creation.
Probably there must be a change in the code in this line:

"ActiveChart.SetSourceData Source:=Sheets(vSheet).Range

("C12:X145"),
PlotBy:=xlColumns"

but I really donīt know how this should look like.

Please help me.

Following the macro, as it looks currently:


----------------------------------------------------------

------------------
---
Sub ChartMakro()

Dim vSheet As String

Num_Sheets = Sheets.Count 'Determine the

number of sheets in
the workbook

For x = 1 To Sheets.Count 'Loop through

all sheets,
beginning with Sheet 2
Sheets

(x).Activate 'Activate the
sheet

vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(vSheet).Range

("C12:X145"),
PlotBy:=xlColumns
Sheets(x).Activate
ActiveChart.Location Whe=xlLocationAsObject,

Name:=ActiveSheet.Name

With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Name

End With


Next

x 'Loop
to next sheet

End Sub
----------------------------------------------------------

------------------
--------------


Probably my posting does not contain my realname in

the "send by" -column. I
donīt know how to change this in Outlook 2000.

Juergen Schweizer


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro for multiple charts

Hi,

I tried this out, but somehow excel doesnīt like the command "(x).Activate".
Maybe I misunderstood something, but the "(x).Activate" command stands at
the beginning of a line, which is not accepted by excel.

Juergen




"DMoney" schrieb im Newsbeitrag
...
Try this out.

Sub ChartMakro()

Dim vSheet As String

Num_Sheets = Sheets.Count 'Determine the
number of sheets inthe Workbook

For x = 1 To Sheets.Count 'Loop through
all sheets,beginning with Sheet 2
Sheets
(x).Activate 'Activate the
sheet

vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(vSheet).Range
("C12:X145"), PlotBy _
:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:=Sheets(vSheet).Name

With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Name

End With


Next
x 'Loop
to next sheet

End Sub
-----Original Message-----
Hello,

I have got a little problem with a macro, that is

intended to create charts
on every sheet of a workbook. The macro runs and creates

all the charts, but
on the sheet that was active when the macro was started.

I.e. there are 17
sheets in a workbook, then there are 17 charts on the

first sheet after the
macro was running. I really donīt know where the bug is.

By the way, I am
not very familiar with macros and I am working with Excel

2000.

Another goody for the macro would be to select a range on

each sheet, and
the macro recognizes these individual ranges for the

chart creation.
Probably there must be a change in the code in this line:

"ActiveChart.SetSourceData Source:=Sheets(vSheet).Range

("C12:X145"),
PlotBy:=xlColumns"

but I really donīt know how this should look like.

Please help me.

Following the macro, as it looks currently:


----------------------------------------------------------

------------------
---
Sub ChartMakro()

Dim vSheet As String

Num_Sheets = Sheets.Count 'Determine the

number of sheets in
the workbook

For x = 1 To Sheets.Count 'Loop through

all sheets,
beginning with Sheet 2
Sheets

(x).Activate 'Activate the
sheet

vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(vSheet).Range

("C12:X145"),
PlotBy:=xlColumns
Sheets(x).Activate
ActiveChart.Location Whe=xlLocationAsObject,

Name:=ActiveSheet.Name

With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Name

End With


Next

x 'Loop
to next sheet

End Sub
----------------------------------------------------------

------------------
--------------


Probably my posting does not contain my realname in

the "send by" -column. I
donīt know how to change this in Outlook 2000.

Juergen Schweizer


.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Macro for multiple charts

the post just truncated the text try this.

Sub ChartMakro()

Dim vSheet As String
Num_Sheets = Sheets.Count
For x = 1 To Sheets.Count
Sheets(x).Activate
vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(vSheet) _
.Range("C12:X145"), PlotBy _
:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, _
Name:=Sheets(vSheet).Name
With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Name
End With
Next x

End Sub
-----Original Message-----
Hi,

I tried this out, but somehow excel doesnīt like the

command "(x).Activate".
Maybe I misunderstood something, but the "(x).Activate"

command stands at
the beginning of a line, which is not accepted by excel.

Juergen




"DMoney" schrieb im

Newsbeitrag
...
Try this out.

Sub ChartMakro()

Dim vSheet As String

Num_Sheets = Sheets.Count 'Determine the
number of sheets inthe Workbook

For x = 1 To Sheets.Count 'Loop through
all sheets,beginning with Sheet 2
Sheets
(x).Activate 'Activate the
sheet

vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets(vSheet).Range
("C12:X145"), PlotBy _
:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:=Sheets(vSheet).Name

With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text = ActiveSheet.Name

End With


Next
x 'Loop
to next sheet

End Sub
-----Original Message-----
Hello,

I have got a little problem with a macro, that is

intended to create charts
on every sheet of a workbook. The macro runs and creates

all the charts, but
on the sheet that was active when the macro was started.

I.e. there are 17
sheets in a workbook, then there are 17 charts on the

first sheet after the
macro was running. I really donīt know where the bug is.

By the way, I am
not very familiar with macros and I am working with Excel

2000.

Another goody for the macro would be to select a range on

each sheet, and
the macro recognizes these individual ranges for the

chart creation.
Probably there must be a change in the code in this line:

"ActiveChart.SetSourceData Source:=Sheets(vSheet).Range

("C12:X145"),
PlotBy:=xlColumns"

but I really donīt know how this should look like.

Please help me.

Following the macro, as it looks currently:


---------------------------------------------------------

-
------------------
---
Sub ChartMakro()

Dim vSheet As String

Num_Sheets = Sheets.Count 'Determine the

number of sheets in
the workbook

For x = 1 To Sheets.Count 'Loop through

all sheets,
beginning with Sheet 2
Sheets

(x).Activate 'Activate the
sheet

vSheet = ActiveSheet.Name

Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets

(vSheet).Range
("C12:X145"),
PlotBy:=xlColumns
Sheets(x).Activate
ActiveChart.Location Whe=xlLocationAsObject,

Name:=ActiveSheet.Name

With ActiveChart
Sheets(x).Activate
.HasTitle = True
.ChartTitle.Characters.Text =

ActiveSheet.Name

End With


Next

x 'Loop
to next sheet

End Sub
---------------------------------------------------------

-
------------------
--------------


Probably my posting does not contain my realname in

the "send by" -column. I
donīt know how to change this in Outlook 2000.

Juergen Schweizer


.



.

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
Macro to create multiple charts? Christina Charts and Charting in Excel 2 January 28th 08 04:06 PM
Charts - How to have multiple charts share a legend. Sean Charts and Charting in Excel 2 November 20th 07 04:49 AM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM
PivotChart formatting: macro for multiple unique charts Jocelyn[_3_] Excel Programming 2 January 20th 04 05:12 PM
PivotChart formatting: macro for multiple unique charts Jocelyn[_3_] Excel Programming 0 January 20th 04 05:09 PM


All times are GMT +1. The time now is 01:13 PM.

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"