arrow diagram

joris511

New Member
Joined
Jun 5, 2016
Messages
1
i want to make a diagram/graph out of a given function.
The diagram (dont know the enlish term) is made out of a line connecting the X axis and the point that is calculated with the function.
I have an example here in this google(r) picture.

In stead of a little dot at the end of the line, it has to be an arrow (pointing up or down)
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi and welcome to the MrExcel Message Board.

I don't think there is such a chart as standard. However, you could add one with a little bit of VBA.
The following code assumes that there is some data in column A:
Code:
Sub Make_Chart()
    Dim i             As Long
    Dim arr1          As Variant
    Dim arrX(1 To 2)  As Variant
    Dim arrY(1 To 2)  As Variant
    Dim newS          As Series

    With ActiveSheet
        arr1 = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
        With .ChartObjects.Add(150, 10, 380, 230).Chart
            .ChartType = xlXYScatterLines
            For i = 1 To UBound(arr1)
                arrX(1) = i: arrY(1) = 0
                arrX(2) = i: arrY(2) = arr1(i, 1)
                Set newS = .SeriesCollection.NewSeries
                With newS
                    .XValues = arrX
                    .Values = arrY
                    .MarkerStyle = xlMarkerStyleNone
                    With .Format.Line
                        .Weight = 1
                        .ForeColor.RGB = RGB(0, 0, 240)
                        .EndArrowheadWidth = msoArrowheadWidthMedium
                        .EndArrowheadStyle = msoArrowheadStealth
                        .EndArrowheadLength = msoArrowheadLong
                    End With
                End With
            Next
        End With
    End With
  
End Sub
The code needs to be pasted in to a new standard code Module.

It just produces a basic chart as it is but all the usual Excel chart features could be added although that would need some more code.

Regards,
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,220
Members
448,554
Latest member
Gleisner2

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