Help with fixing procedure. (Should be easy)

andrew456

New Member
Joined
Nov 2, 2014
Messages
31
Can someone please help me fix my procedure? I cannot debug because the debugger sees nothing wrong.

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 = ActiveCell.Row

*

*

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, 20), Cells(AnotherRow, 31))

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("Sheet1").Range("T17:AE17")

tSeries.Border.Weight = xlThick

tSeries.Border.LineStyle = xlContinuous

tSeries.Smooth = True

*

*

*

*

*

*

*

oChtObj.Visible = True

*

*

*

End Sub

*

*

The second line/series isn't showing and I do not know why. Can someone help?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Could you format your code with CODE tags?
 
Upvote 0
I don't think you can edit your messages after a certain time it has been published; nect time just select all the code and use the symbol # in the toolbox above the area in which you type the text.

Anyway to understand what goes on with your code you should remove the line "On Error Resume Next" (that just hide errors when they are found); to get support from us I recommend you attach a sample file, so that we have not to spend time trying to understand you data layout and recreating it.

Bye
 
Last edited:
Upvote 0
And let me suggest to avoid commenting "should be easy", if you wish that real experts have a look to your question.
 
Upvote 0
So, what is actually wrong with the code ?
Error message ?
Wrong information / result ?
Nothing happens ?

Code:
Sub UpdateChart2()
Dim oChtObj As ChartObject, oSeries As Series, tSeries As Series
Dim UserRow As Long, AnotherRow As Long
Set oChtObj = ActiveSheet.ChartObjects(1)
On Error Resume Next
UserRow = ActiveCell.Row
AnotherRow = ActiveCell.Row
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, 20), Cells(AnotherRow, 31))
            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("Sheet1").Range("T17:AE17")
tSeries.Border.Weight = xlThick
tSeries.Border.LineStyle = xlContinuous
tSeries.Smooth = True
oChtObj.Visible = True
End Sub
 
Upvote 0
So, what is actually wrong with the code ?
Error message ?
Wrong information / result ?
Nothing happens ?

Code:
Sub UpdateChart2()
Dim oChtObj As ChartObject, oSeries As Series, tSeries As Series
Dim UserRow As Long, AnotherRow As Long
Set oChtObj = ActiveSheet.ChartObjects(1)
On Error Resume Next
UserRow = ActiveCell.Row
AnotherRow = ActiveCell.Row
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, 20), Cells(AnotherRow, 31))
            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("Sheet1").Range("T17:AE17")
tSeries.Border.Weight = xlThick
tSeries.Border.LineStyle = xlContinuous
tSeries.Smooth = True
oChtObj.Visible = True
End Sub

Sorry for responding so late. The problem with the code is that I want two graphs showing on the same chart. The code does not work because it is still only showing one graph on the chart (oSeries). The second graph is the tSeries. How can I make this code work to display the tSeries as well as the oSeries? I cannot debug this because it the syntax has no errors. But it isn't doing what I want it to do. Any help is appreciated.
 
Upvote 0
Well you can debug it by using F8 and stepping through each line manually.
If you do this and see if the tseries is actually being created.
Can you upload the worksheet to Dropbox and we may be able to take a closer look using your data !!
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,921
Members
449,195
Latest member
Stevenciu

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