Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Excel graph (newbie)


Hello Group,

I'm new to Excel programming and currently have written a module that
sends a query to a server. Gets some information then it populates
sheet1. Next step is clicking a button which takes the user to a tab as
Chart1 and shows a grap based on data. Of course, each report is
generated base on one column of the sheet. For instance I have:

Day of moth Accidents Col2
Col3
1 345
2 23
3 114
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Excel graph (newbie)



I had forogt to past my code. The second thread has it.


On Dec 18, 10:59 am, "Amit" wrote:
Hello Group,

I'm new to Excel programming and currently have written a module that
sends a query to a server. Gets some information then it populates
sheet1. Next step is clicking a button which takes the user to a tab as
Chart1 and shows a grap based on data. Of course, each report is
generated base on one column of the sheet. For instance I have:

Day of moth Accidents Col2
Col3
1 345
2 23
3 114
.
.
.
30 78

Problem:

Each column is different so reports are related only to associated
column in sheet1 but they all have a time range of a month. So I need o
have X label as Day of Month (X axies) which never appears in my
graph! "this is one problem". It shows only number "1" the 15 day of
month.

also, as you will see I have sent the bar color to be green (in
following code) but sometimes they automatically chage to different
color (each bar gets a different color!) or at least the last one get
purple color to itself.

I will appreciate it some of you could give me advice on this problem.




Dim TheChart As Chart
Dim DataSheet As Worksheet
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range
Dim iBarIndex As Integer

Set TheChart = Sheets("Chart1")
Set DataSheet = Sheets("Sheet1")

With DataSheet
Set CatTitles = .Range("B7:B7")
Set SrcRange = .Range(Cells(8, Item), .Cells(37, Item))
End With

'Source Data
Set SourceData = Union(CatTitles, SrcRange)

With TheChart

.Activate

For iBarIndex = 1 To ActiveChart.SeriesCollection.Count
.SeriesCollection(iBarIndex).Interior.Color = RGB(0, 128,
0) '123
Next iBarIndex

.ChartGroups(1).Overlap = -35
.ChartGroups(1).GapWidth = 200
.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData

.Deselect

End With

'With ActiveChart.Axes(xlValue)
' .HasMajorGridlines = True
' .HasMinorGridlines = False
' End With

' Application.ScreenUpdating = True

'With ActiveChart.Axes(xlCategory)
' .HasMajorGridlines = False
' .HasMinorGridlines = False
'End With

Sincerely,
Amit.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Excel graph (newbie)

In this line

.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData

change PlotBy:=xlRows to PlotBy:=xlColumns so it reads

.SetSourceData Source:=SourceData, PlotBy:=xlColumns 'SourceData

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


"Amit" wrote in message
ups.com...


I had forogt to past my code. The second thread has it.


On Dec 18, 10:59 am, "Amit" wrote:
Hello Group,

I'm new to Excel programming and currently have written a module that
sends a query to a server. Gets some information then it populates
sheet1. Next step is clicking a button which takes the user to a tab as
Chart1 and shows a grap based on data. Of course, each report is
generated base on one column of the sheet. For instance I have:

Day of moth Accidents Col2
Col3
1 345
2 23
3 114
.
.
.
30 78

Problem:

Each column is different so reports are related only to associated
column in sheet1 but they all have a time range of a month. So I need o
have X label as Day of Month (X axies) which never appears in my
graph! "this is one problem". It shows only number "1" the 15 day of
month.

also, as you will see I have sent the bar color to be green (in
following code) but sometimes they automatically chage to different
color (each bar gets a different color!) or at least the last one get
purple color to itself.

I will appreciate it some of you could give me advice on this problem.




Dim TheChart As Chart
Dim DataSheet As Worksheet
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range
Dim iBarIndex As Integer

Set TheChart = Sheets("Chart1")
Set DataSheet = Sheets("Sheet1")

With DataSheet
Set CatTitles = .Range("B7:B7")
Set SrcRange = .Range(Cells(8, Item), .Cells(37, Item))
End With

'Source Data
Set SourceData = Union(CatTitles, SrcRange)

With TheChart

.Activate

For iBarIndex = 1 To ActiveChart.SeriesCollection.Count
.SeriesCollection(iBarIndex).Interior.Color = RGB(0, 128,
0) '123
Next iBarIndex

.ChartGroups(1).Overlap = -35
.ChartGroups(1).GapWidth = 200
.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData

.Deselect

End With

'With ActiveChart.Axes(xlValue)
' .HasMajorGridlines = True
' .HasMinorGridlines = False
' End With

' Application.ScreenUpdating = True

'With ActiveChart.Axes(xlCategory)
' .HasMajorGridlines = False
' .HasMinorGridlines = False
'End With

Sincerely,
Amit.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Excel graph (newbie)


Hello Jon,

Thank you so much. Yes. that was the problem. I truly appreciate your
response. However, what I don't understand is why the graph bars' color
keep changing !!!
Also, is there any solution to make the chart readonly? to avoid
changes by user?

Once again thanks,
Amit




On Dec 18, 1:53 pm, "Jon Peltier"
wrote:
In this line

.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData

change PlotBy:=xlRows to PlotBy:=xlColumns so it reads

.SetSourceData Source:=SourceData, PlotBy:=xlColumns 'SourceData

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

"Amit" wrote in oglegroups.com...





I had forogt to past my code. The second thread has it.


On Dec 18, 10:59 am, "Amit" wrote:
Hello Group,


I'm new to Excel programming and currently have written a module that
sends a query to a server. Gets some information then it populates
sheet1. Next step is clicking a button which takes the user to a tab as
Chart1 and shows a grap based on data. Of course, each report is
generated base on one column of the sheet. For instance I have:


Day of moth Accidents Col2
Col3
1 345
2 23
3 114
.
.
.
30 78


Problem:


Each column is different so reports are related only to associated
column in sheet1 but they all have a time range of a month. So I need o
have X label as Day of Month (X axies) which never appears in my
graph! "this is one problem". It shows only number "1" the 15 day of
month.


also, as you will see I have sent the bar color to be green (in
following code) but sometimes they automatically chage to different
color (each bar gets a different color!) or at least the last one get
purple color to itself.


I will appreciate it some of you could give me advice on this problem.


Dim TheChart As Chart
Dim DataSheet As Worksheet
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range
Dim iBarIndex As Integer


Set TheChart = Sheets("Chart1")
Set DataSheet = Sheets("Sheet1")


With DataSheet
Set CatTitles = .Range("B7:B7")
Set SrcRange = .Range(Cells(8, Item), .Cells(37, Item))
End With


'Source Data
Set SourceData = Union(CatTitles, SrcRange)


With TheChart


.Activate


For iBarIndex = 1 To ActiveChart.SeriesCollection.Count
.SeriesCollection(iBarIndex).Interior.Color = RGB(0, 128,
0) '123
Next iBarIndex


.ChartGroups(1).Overlap = -35
.ChartGroups(1).GapWidth = 200
.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData


.Deselect


End With


'With ActiveChart.Axes(xlValue)
' .HasMajorGridlines = True
' .HasMinorGridlines = False
' End With


' Application.ScreenUpdating = True


'With ActiveChart.Axes(xlCategory)
' .HasMajorGridlines = False
' .HasMinorGridlines = False
'End With


Sincerely,
Amit.- Hide quoted text -- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Excel graph (newbie)

If you plot a column of data by rows, each row becomes its own series with
its own distinct colors.

To protect the chart:
http://peltiertech.com/Excel/ChartsH...rotection.html

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


"Amit" wrote in message
ups.com...

Hello Jon,

Thank you so much. Yes. that was the problem. I truly appreciate your
response. However, what I don't understand is why the graph bars' color
keep changing !!!
Also, is there any solution to make the chart readonly? to avoid
changes by user?

Once again thanks,
Amit




On Dec 18, 1:53 pm, "Jon Peltier"
wrote:
In this line

.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData

change PlotBy:=xlRows to PlotBy:=xlColumns so it reads

.SetSourceData Source:=SourceData, PlotBy:=xlColumns 'SourceData

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

"Amit" wrote in
oglegroups.com...





I had forogt to past my code. The second thread has it.


On Dec 18, 10:59 am, "Amit" wrote:
Hello Group,


I'm new to Excel programming and currently have written a module that
sends a query to a server. Gets some information then it populates
sheet1. Next step is clicking a button which takes the user to a tab
as
Chart1 and shows a grap based on data. Of course, each report is
generated base on one column of the sheet. For instance I have:


Day of moth Accidents Col2
Col3
1 345
2 23
3 114
.
.
.
30 78


Problem:


Each column is different so reports are related only to associated
column in sheet1 but they all have a time range of a month. So I need
o
have X label as Day of Month (X axies) which never appears in my
graph! "this is one problem". It shows only number "1" the 15 day of
month.


also, as you will see I have sent the bar color to be green (in
following code) but sometimes they automatically chage to different
color (each bar gets a different color!) or at least the last one get
purple color to itself.


I will appreciate it some of you could give me advice on this problem.


Dim TheChart As Chart
Dim DataSheet As Worksheet
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range
Dim iBarIndex As Integer


Set TheChart = Sheets("Chart1")
Set DataSheet = Sheets("Sheet1")


With DataSheet
Set CatTitles = .Range("B7:B7")
Set SrcRange = .Range(Cells(8, Item), .Cells(37, Item))
End With


'Source Data
Set SourceData = Union(CatTitles, SrcRange)


With TheChart


.Activate


For iBarIndex = 1 To ActiveChart.SeriesCollection.Count
.SeriesCollection(iBarIndex).Interior.Color = RGB(0, 128,
0) '123
Next iBarIndex


.ChartGroups(1).Overlap = -35
.ChartGroups(1).GapWidth = 200
.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData


.Deselect


End With


'With ActiveChart.Axes(xlValue)
' .HasMajorGridlines = True
' .HasMinorGridlines = False
' End With


' Application.ScreenUpdating = True


'With ActiveChart.Axes(xlCategory)
' .HasMajorGridlines = False
' .HasMinorGridlines = False
'End With


Sincerely,
Amit.- Hide quoted text -- Show quoted text -






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Excel graph (newbie)



Hi Jon again,

Yes that was the solution. I truly appreciate your help.

Thanks and merry Christmas



On Dec 19, 5:19 am, "Jon Peltier"
wrote:
If you plot a column of data by rows, each row becomes its own series with
its own distinct colors.

To protect the chart:
http://peltiertech.com/Excel/ChartsH...rotection.html

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

"Amit" wrote in oglegroups.com...





Hello Jon,


Thank you so much. Yes. that was the problem. I truly appreciate your
response. However, what I don't understand is why the graph bars' color
keep changing !!!
Also, is there any solution to make the chart readonly? to avoid
changes by user?


Once again thanks,
Amit


On Dec 18, 1:53 pm, "Jon Peltier"
wrote:
In this line


.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData


change PlotBy:=xlRows to PlotBy:=xlColumns so it reads


.SetSourceData Source:=SourceData, PlotBy:=xlColumns 'SourceData


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


"Amit" wrote in
oglegroups.com...


I had forogt to past my code. The second thread has it.


On Dec 18, 10:59 am, "Amit" wrote:
Hello Group,


I'm new to Excel programming and currently have written a module that
sends a query to a server. Gets some information then it populates
sheet1. Next step is clicking a button which takes the user to a tab
as
Chart1 and shows a grap based on data. Of course, each report is
generated base on one column of the sheet. For instance I have:


Day of moth Accidents Col2
Col3
1 345
2 23
3 114
.
.
.
30 78


Problem:


Each column is different so reports are related only to associated
column in sheet1 but they all have a time range of a month. So I need
o
have X label as Day of Month (X axies) which never appears in my
graph! "this is one problem". It shows only number "1" the 15 day of
month.


also, as you will see I have sent the bar color to be green (in
following code) but sometimes they automatically chage to different
color (each bar gets a different color!) or at least the last one get
purple color to itself.


I will appreciate it some of you could give me advice on this problem.


Dim TheChart As Chart
Dim DataSheet As Worksheet
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range
Dim iBarIndex As Integer


Set TheChart = Sheets("Chart1")
Set DataSheet = Sheets("Sheet1")


With DataSheet
Set CatTitles = .Range("B7:B7")
Set SrcRange = .Range(Cells(8, Item), .Cells(37, Item))
End With


'Source Data
Set SourceData = Union(CatTitles, SrcRange)


With TheChart


.Activate


For iBarIndex = 1 To ActiveChart.SeriesCollection.Count
.SeriesCollection(iBarIndex).Interior.Color = RGB(0, 128,
0) '123
Next iBarIndex


.ChartGroups(1).Overlap = -35
.ChartGroups(1).GapWidth = 200
.SetSourceData Source:=SourceData, PlotBy:=xlRows 'SourceData


.Deselect


End With


'With ActiveChart.Axes(xlValue)
' .HasMajorGridlines = True
' .HasMinorGridlines = False
' End With


' Application.ScreenUpdating = True


'With ActiveChart.Axes(xlCategory)
' .HasMajorGridlines = False
' .HasMinorGridlines = False
'End With


Sincerely,
Amit.- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -


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
Newbie trying to graph wooljr Charts and Charting in Excel 2 June 4th 08 09:47 PM
How to plot graph (newbie) Lamb Chop Excel Discussion (Misc queries) 2 August 10th 07 09:16 PM
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Graph Excel Selection, Open Word File, Embed Graph Into Word Steve Excel Programming 0 November 17th 03 05:35 PM
Newbie help...VBA w/ Excel Joe Excel Programming 3 August 11th 03 11:30 PM


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