Adding an Axis to VBA/Macro

Moxioron

Registered User.
Local time
Today, 14:00
Joined
Jul 11, 2012
Messages
68
Hello all.

I have a graph in Excel that I created three different graphs for. Each graph is triggered by a button tied to a macro. All works great except the last one.

I want it to have two Axis and it doesn't seem to be registering. Here is my code below.

Thanks for your help.

' BothCreditLineandNumber Macro
'
' Keyboard Shortcut: Ctrl+Shift+T
Sub BothCreditLineandNumber()
Sheets("Roll-up").Unprotect "lending88"
With ActiveSheet.ChartObjects(1).Chart
'Removes old series:
Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop
'Adds new series:
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Name = "Credit Lines"
.Values = "='Roll-up'!$K$3:$K$8"
.XValues = "='Roll-up'!$A$3:A8"
End With

With .SeriesCollection.NewSeries
.Name = "New VISAs Booked"
.Values = "='Roll-up'!$J$3:$J$8"
.XValues = "='Roll-up'!$A$3:A8"
.AxisGroup = 2
End With

.ChartType = xlLine

End With
Sheets("Roll-up").Protect "lending88"
End Sub
 
Haven't been through your code specifically, but found this on another site. Perhaps it will help. The second axis is a tough one.
Code:
With .SeriesCollection(MyInteger)
             .XValues = WS.Range(WS.Cells(StartRow, 1), WS.Cells(LastRow, 1))
             .Values = WS.Range(WS.Cells(StartRow, 6), WS.Cells(LastRow, 6))
             [B].AxisGroup = xlSecondary[/B]
             .Format.Line.Visible = False
             .MarkerStyle = xlMarkerStyleDiamond  'xlMarkerStyleX ' or xlMarkerStylePlus...
             .MarkerBackgroundColor = RGB(255, 255, 255) 
             .MarkerForegroundColor = RGB(0, 0, 255) 
             .MarkerSize = 7 ' use values 2 to 72
        End With
also
.Axes(xlTimeScale).HasMajorGridlines = True ' might be useful

You apper to have an excellent grasp on this.
For other viewers look at Axis Members and Axis
http://msdn.microsoft.com/en-us/library/ff195770(v=office.15).aspx

Here is another solution that helped me once. I keep it bookmarked.
http://www.tek-tips.com/viewthread.cfm?qid=766397
 

Users who are viewing this thread

Back
Top Bottom