LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Setting chart Xvalue errors

I am building charts with non-contiguous ranges. I have struggled
through allot with this but am stumped at getting
SeriesCollection(#).XValues to work correctly. the different syntax I
have tried either gives me an "unable to set the xvalues property of
the series class" error or the results in the source data Catagory X
axis Labels look like :
={"$H$1","$J$1","$L$1","$N$1","$P$1","$R$1","$T$1" ,"$V$1","$X$1"}
with that curved bracket and sometimes extra quotes...
As you can see by the number of .SeriesCollection(1).XValues = xValRng
variations, I have given up any logical approach and am now easter
egging.

Any help will be met with eternal gratitude!

Sub AddChart()
Dim aChart As Chart
Dim shtNm As String
Dim chtLoc1 As Range
Dim srcRng As Range
Dim hdrRow As Range
Dim numRows As Integer
Dim numColumns As Integer
Dim dataTyp As String
Dim c As Range
Dim firstAdd As String
Dim xVal As String
Dim xValRng As Range

dataTyp = "IMP"
shtNm = ActiveSheet.Name

ActiveSheet.ChartObjects.Delete

Set hdrRow = Range(Range("A1"), Selection.End(xlToRight)) '.Select

With hdrRow
Set c = .find(dataTyp, LookIn:=xlValues)
If Not c Is Nothing Then
firstAdd = c.Address
Do
If c.Address = firstAdd Then
xVal = shtNm & "!" & c.Address
Else
xVal = xVal & "," + shtNm & "!" & c.Address
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAdd
End If
End With

shtNm = ActiveSheet.Name
Set chtLoc1 = Range("dc_res")
Set aChart = Charts.Add
Set aChart = aChart.Location(Whe=xlLocationAsObject,
Name:=shtNm)


With aChart
.ChartType = xlLineMarkers


Set srcRng = Union(Sheets(shtNm).Range("CODE"),
Range("IMP_100_Hz"), Range("IMP_200_Hz"), Range("IMP_400_Hz"), _
Range("IMP_1_kHz"), Range("IMP_2_kHz"), Range("IMP_4_kHz"), _
Range("IMP_10_kHz"), Range("IMP_20_kHz"), Range("IMP_40_kHz"))

.SetSourceData Source:=srcRng, _
PlotBy:=xlRows

Debug.Print xVal

Set xValRng = Range(xVal)
xValRng.Select

'.SeriesCollection(1).XValues = .xValRng.Address
'.SeriesCollection(1).XValues = xValRng.Value
'.SeriesCollection(1).XValues = xValRng
'unable to set the xvalues property of the series class
'.SeriesCollection(1).XValues = xVal
'.SeriesCollection(1).XValues =
Worksheets(shtNm).xValRng.Address
'.SeriesCollection(1).XValues =
Worksheets(shtNm).Range(xVal).Address
'.SeriesCollection(1).XValues = Worksheets(shtNm).xVal
.SeriesCollection(1).XValues = xValRng


.HasTitle = True
.ChartTitle.Text = "Configuration " & shtNm & " Impedance"
With .Parent
.Top = chtLoc1.Offset(10, 0).Top
.Left = chtLoc1.Left
.Height = 252
.Width = 432
.Name = shtNm & "ChartDev"
End With
End With
End Sub

 
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
2graph with the same Xvalue and same Size of graph c06 Charts and Charting in Excel 1 April 10th 06 03:47 PM
Charts with Xvalue and YValue? deko[_2_] Excel Programming 2 March 8th 05 08:34 AM
How to get corresponding Xvalue for specific Yvalue from XYScatte. azmodeus Charts and Charting in Excel 5 January 16th 05 02:45 PM
InitializeComponent() errors, Setting values in another form Jeff Morhous Excel Programming 1 February 9th 04 12:13 PM
vc++ automation: opening chart as chart window and setting scale Mike Biolsi Excel Programming 0 February 7th 04 08:13 AM


All times are GMT +1. The time now is 08:00 AM.

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"