Help with updating active cell chart

andrew456

New Member
Joined
Nov 2, 2014
Messages
31
Hello,

I am trying to adjust a working active cell chart and that changes depending on the cell selected. I want to add a second series based on a table from Sheet 3. The second table is the same as the first in terms of format but the only difference is the numbers. The second series is listed as tSeries and the second row is called AnotherRow. This what I have so far.




Sub UpdateChart2()

*

Dim oChtObj As ChartObject

*

Dim oSeries As Series

*

Dim tSeries As Series

*

Dim UserRow As Long

*

Dim AnotherRow As Long

*

*

Set oChtObj = ActiveSheet.ChartObjects(1)

*

On Error Resume Next

*

UserRow = ActiveCell.Row

*

AnotherRow.

*

If UserRow < 4 Or IsEmpty(Cells(UserRow, 1)) Then

*

oChtObj.Visible = False

*

*

Else

*

With oChtObj

With .Chart

If .SeriesCollection.Count = 0 Then

Set oSeries = .SeriesCollection.NewSeries

Set tSeries = .SeriesCollection.NewSeries

*

*

Else

*

Set oSeries = .SeriesCollection(1)

Set tSeries = .SeriesCollection(2)

*

End If

*

tSeries.Values = Range(Cells(AnotherRow, 2), Cells(AnotherRow, 13))

oSeries.Values = Range(Cells(UserRow, 2), Cells(UserRow, 13))

.HasTitle = True

.ChartTitle.Text = Cells(UserRow, 1).Text

.ChartType = xlLine

*

*

End With

*

.Visible = True

*

*

End With

*

End If

*

*

*

*

*

oSeries.XValues = Worksheets("Sheet1").Range("B17:M17")

*

oSeries.Border.Weight = xlThick

oSeries.Border.LineStyle = xlContinuous

oSeries.Smooth = True

tSeries.XValues Worksheets("Sheet3").Range("B17:M17")

tSeries.Border.Weight = xlThick

tSeries.Border.LineStyle = xlContinious

tSeries.Smooth = True

*

*

*

*

*

*

*

oChtObj.Visible = True

*

*

*

End Sub

*
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top