Insert line in graph with macro

elbartje

New Member
Joined
Oct 28, 2015
Messages
39
I want to insert a line in a graph the x en y data needs to come from an userform (an input box is also ok).
I dont want to select a range of cells but directly enter a value(s) for the x and y data.
This data should not be put in cells but only in the graph itself

So I select a graph, run the macro I get a popup to enter x and y data for example X1=0 X2=10 and Y1=120 and Y2=120.
Now a horizontal line is plotted in the graph.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I just had to add an extra graph in the main graph with 2 points on y axis, then change type of graph so it becomes a straight horizontal line, then change data source for x axis so it becomes a vertical line.
 
Upvote 0

Forum statistics

Threads
1,222,629
Messages
6,167,190
Members
452,104
Latest member
jadethejade

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