Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 text labels in category axis - missing labels | Charts and Charting in Excel | |||
Category (X) Axis Labels not found in Excel 2003 | Charts and Charting in Excel | |||
Missing Axis Category Labels | Charts and Charting in Excel | |||
Appearance two labels on category axis | Charts and Charting in Excel | |||
In a bar chart, how do I change the x-axis "category" labels? | Excel Discussion (Misc queries) |