Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel automation, change Category (X) Axis Labels, VB6

Hello,
I put some data to excel sheet from Access DB through VB6. I can create charts but I can set the labels for the X axes. For example if I set data for charts as :
| A | B |
1 | 3 | 10 |
2 | 4 | 25 |
3 | 5 | 55 |

Excel Automaticaly set LAbels for X-axes as: 3,4,5, and Y Values as 10,25,55. Because Title and value columns are next to each other.
But in my case I want Y values as Column B1:B3 and X labels as E1:E3 which is not next to column B.
| A | B | C | D | E |
1 | X | 10 | X | X | 3 |
2 | X | 25 | X | X | 4 |
3 | X | 55 | X | X | 5 |
Manually this can be done by changing Category (X) Axis Labels on Excel Chart's Source Data options.

Is there any way to do that by programming.

I use this sample code .
----------------------------------------------
Dim new_chart As Chart
Set new_chart = Charts.Add()

With new_chart
.ChartType = xlLineMarkers
.HasLegend = False
.SetSourceData Source:=active_sheet.Range("B1:B3), PlotBy:=xlColumns
.Location Whe=xlLocationAsObject, Name:=active_sheet.Name
End With

active_sheet.Shapes(active_sheet.Shapes.Count).Top = 10
active_sheet.Shapes(active_sheet.Shapes.Count).Lef t = _
100
active_sheet.Shapes(active_sheet.Shapes.Count).Wid th = _
600
active_sheet.Shapes(active_sheet.Shapes.Count).Hei ght = _
400


ActiveChart.ChartArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Monthly BSP Index"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, _
xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text _
= "Value"
End With



Submitted via EggHeadCafe - Software Developer Portal of Choice
Building Websites with DotNetNuke
http://www.eggheadcafe.com/tutorials...s-with-do.aspx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel automation, change Category (X) Axis Labels, VB6

With new_chart
.........
.SeriesCollection(1).XValues=active_sheet.Range("E 1:E3")
End With

Gerald

<Zico Damatsu schrieb im Newsbeitrag
...
Hello,
I put some data to excel sheet from Access DB through VB6. I can create
charts but I can set the labels for the X axes. For example if I set data
for charts as :
| A | B |
1 | 3 | 10 |
2 | 4 | 25 |
3 | 5 | 55 |

Excel Automaticaly set LAbels for X-axes as: 3,4,5, and Y Values as
10,25,55. Because Title and value columns are next to each other.
But in my case I want Y values as Column B1:B3 and X labels as E1:E3 which
is not next to column B.
| A | B | C | D | E |
1 | X | 10 | X | X | 3 |
2 | X | 25 | X | X | 4 |
3 | X | 55 | X | X | 5 |
Manually this can be done by changing Category (X) Axis Labels on Excel
Chart's Source Data options.

Is there any way to do that by programming.

I use this sample code .
----------------------------------------------
Dim new_chart As Chart
Set new_chart = Charts.Add()

With new_chart
.ChartType = xlLineMarkers
.HasLegend = False
.SetSourceData Source:=active_sheet.Range("B1:B3), PlotBy:=xlColumns
.Location Whe=xlLocationAsObject, Name:=active_sheet.Name
End With

active_sheet.Shapes(active_sheet.Shapes.Count).Top = 10
active_sheet.Shapes(active_sheet.Shapes.Count).Lef t = _
100
active_sheet.Shapes(active_sheet.Shapes.Count).Wid th = _
600
active_sheet.Shapes(active_sheet.Shapes.Count).Hei ght = _
400


ActiveChart.ChartArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Monthly BSP Index"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, _
xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text _
= "Value"
End With



Submitted via EggHeadCafe - Software Developer Portal of Choice
Building Websites with DotNetNuke
http://www.eggheadcafe.com/tutorials...s-with-do.aspx



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
Excel 2007 text labels in category axis - missing labels Boris Charts and Charting in Excel 3 December 5th 08 04:33 PM
Category (X) Axis Labels not found in Excel 2003 vrk1 Charts and Charting in Excel 2 March 12th 08 08:11 PM
Missing Axis Category Labels CruisJR Charts and Charting in Excel 1 March 29th 07 06:42 PM
Appearance two labels on category axis blaforge Charts and Charting in Excel 1 June 25th 06 02:35 PM
In a bar chart, how do I change the x-axis "category" labels? thermactor Excel Discussion (Misc queries) 1 December 2nd 05 07:19 AM


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