Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pim Pim is offline
external usenet poster
 
Posts: 1
Default Excel Charts & VBA


Hi folks,
I'm baffled- I'm writing a macro to pull a data table into an exce
sheet & create a bargraph of those results. The number of records i
the data table are variable (say between 2 and 50).

I'm trying to define a dynamic bar graph using VBA. The X values ar
in col C and the text Y vlaues are in col A. (both start in row 3) Th
values in column B are necessary, but have nothing to do with th
graph. I'm having trouble using variables to define the source data a
two, non adjacent ranges.

I've had problems just including the 50 cells in the data table as i
includes blank
spaces in the chart.

The code below builds the graph based on the X values starting in cel
C3. It just numbers them on the Y axis, not by the corresponding tex
values....

Any ideas?
Thanks
pim

Dim sheetName as String 'name of the sheet where the data table
Dim NoRec As Double 'Number of records returned in query
Dim Graph As ChartObject 'Bar graph

NoRec = Application.WorksheetFunction.CountA(Columns("A:A" ))
Set Graph = ActiveSheet.ChartObjects.Add _
(Left:=285, Width:=548, Top:=40, Height:=825)
Graph.Chart.SetSourceDat
Source:=Sheets(sheetName).Range(Cells(3, 3), Cells(NoRec, 3))

Graph.Chart.ChartType = xlBarClustered
ActiveSheet.ChartObjects(1).Activate

ActiveChart.HasLegend = False
ActiveChart.HasTitle = False
With ActiveChart.ChartGroups(1)
.Overlap = 0
.GapWidth = 140
.HasSeriesLines = False
End With
With ActiveChart.ChartGroups(1)
.Overlap = 0
.GapWidth = 140
.HasSeriesLines = False
End With
'Y axis- text names format
With ActiveChart.Axes(xlCategory)
.CrossesAt = 1
.TickLabelSpacing = 1
.TickMarkSpacing = 1
.AxisBetweenCategories = True
.ReversePlotOrder = True
.MajorTickMark = xlOutside
.MinorTickMark = xlNone
.TickLabelPosition = xlLow
End With
'X axis-PI values Format
With ActiveChart.Axes(xlValue)
.TickLabelPosition = xlHigh
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End Wit

--
Pi
-----------------------------------------------------------------------
Pim's Profile: http://www.excelforum.com/member.php...fo&userid=2756
View this thread: http://www.excelforum.com/showthread.php?threadid=47113

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
Unable to click on charts & unable to create any new charts Excel Snapclick Charts and Charting in Excel 4 February 1st 09 07:59 PM
link excel charts to web pages and update charts automatically Signguy Charts and Charting in Excel 1 April 22nd 08 08:29 PM
Charts - How to have multiple charts share a legend. Sean Charts and Charting in Excel 2 November 20th 07 04:49 AM
Matching the colors Column Charts and Pie Charts RohanSewgobind Charts and Charting in Excel 3 April 21st 06 09:35 PM
URGENT - NEED PRO EXCEL PROGRAMMER - TO AUTOMATICALLY CHANGE TITLES IN EXCEL CHARTS Marcello do Guzman Excel Programming 2 October 7th 03 05:11 PM


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