Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Choose diagram
Lars:
Why not to select chart directly? Much better. As an example have my procedure, which sets the height and width of the selected chart by input values. Selected can be the same chart elements as you normally use. It is enabled by means of Parent property. You can set analogous Chart properties (.Axes etc.) in the same way. PB Sub ChartSize() 'Sets the dimensions of selected chart in mm Dim ErrMsg As String, MB As Long Const PointSize = 2.83, TMB = "Chart size" On Error GoTo NoSelection Set S = Selection.Parent If S.Type < -4169 Then ErrMsg = "No chart": GoTo ErrExit ChartHeight = InputBox("Height /mm", TMB, 85) If ChartHeight = "" Then Exit Sub ChartWidth = InputBox("Width /mm", TMB, 100) If ChartWidth = "" Then Exit Sub ErrMsg = "Incorrect object" On Error GoTo ErrExit S.Parent.Height = ChartHeight * PointSize S.Parent.Width = ChartWidth * PointSize GoTo EndExit NoSelection: ErrMsg = "Nothing" ErrExit: MB = MsgBox(ErrMsg & " was selected", vbCritical, TMB) EndExit: On Error GoTo 0 End Sub -----Original Message----- Hi I have made this workbook with 4 diagrams in each sheet (Diagram 1, Diagram 2 etc.). I have made the following macro, so you can manually set x and y values. Now I want to know how I can decide (as first inputbox) what diagram I want my manual x and y values to refer to. I was thinking of a list where I could choose between 4 names and then each name refers to one of the diagrams (Diagram 1, etc.). Here is my code: Sub x_y_akser() ' ' x_y_akser Makro ' Makro indspillet 21-08-2003 af LPN ' ' Program: On Error GoTo fejlzone ymin = Application.InputBox("Indtast min på Y- asken", "Minimum Y") ymax = Application.InputBox("Indtast max. på Y- aksen", "Maximum Y") mellemrum = Application.InputBox("Indtast mellemrum på Y- aksen", "Mellemrum på Y-aksen") xmin = Application.InputBox("Indtast min. på X- aksen", "Minimum X") xmax = Application.InputBox("Indtast max. på X- aksen", "Maximum X") mellemrumx = Application.InputBox("Indtast mellem på X- aksen", "Mellemrum på X-aksen") ActiveSheet.ChartObjects("Diagram 1").Activate With ActiveChart.Axes(xlValue) .MinimumScale = ymin .MaximumScale = ymax .MinorUnit = mellemrum .MajorUnit = mellemrum .Crosses = xlCustom .CrossesAt = ymin .ReversePlotOrder = False .ScaleType = xlLinear .DisplayUnit = xlNone End With With ActiveChart.Axes(xlCategory) .MinimumScale = xmin .MaximumScale = xmax .MinorUnit = mellemrumx .MajorUnit = mellemrumx .Crosses = xlCustom .CrossesAt = xmin .ReversePlotOrder = False .ScaleType = xlLinear .DisplayUnit = xlNone End With Range("a1").Select Exit Sub fejlzone: MsgBox ("Der opstod en fejl - husk der skal indtastet en værdi"), vbCritical GoTo Program End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to make this diagram? | New Users to Excel | |||
Diagram | Excel Discussion (Misc queries) | |||
How to plot Z value instead of a dot in a xy-diagram | Excel Discussion (Misc queries) | |||
Diagram | Excel Discussion (Misc queries) | |||
excel diagram | Charts and Charting in Excel |