X, Y Graph

  • Thread starter Thread starter Noone
  • Start date Start date
N

Noone

Hi,
Is there a way to automatically plot an x,y graph in which
x will be varied from n to m in k steps?

The y value is calculated in the same spreadsheet using multiple formulas
throughout the spreadsheet (So it is not a single formula in a single cell).

Michael
 
Michael,

An easy way is to use a macro to vary X and record both X and Y in a table. It is easier in Excel 2000 or higher, since you can
force a calculation a little better.

For example, if you enter X into Cell A1, and all the intermediate formulas result in the final value in cell A10, with nothing in
either columns B or C (which is where I will put the resulting table) the sub below will generate the table, which you can then use
to create your graph. You can make the graph generation into a macro as well.

HTH,
Bernie
Excel MVP

Sub TryNow()
Dim X As Double
Dim N As Double
Dim M As Double
Dim K As Integer

N = 1
M = 10
'Enter the number of values you want, rather than steps
K = 6

For X = N To M Step (M - N) / (K - 1)
Range("A1").Value = X
Application.CalculateFull
Range("B65536").End(xlUp)(2).Value = X
Range("C65536").End(xlUp)(2).Value = Range("A10").Value
Next

End Sub
 
Back
Top