Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PB PB is offline
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make this diagram? Thomas Andersson New Users to Excel 1 September 30th 09 03:44 PM
Diagram Kathrine Excel Discussion (Misc queries) 0 March 6th 08 08:56 AM
How to plot Z value instead of a dot in a xy-diagram xYeti Excel Discussion (Misc queries) 2 August 7th 06 10:38 PM
Diagram roffe Excel Discussion (Misc queries) 1 May 14th 06 12:01 AM
excel diagram shortz00 Charts and Charting in Excel 1 March 22nd 06 09:53 PM


All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"