D
deltaquattro
Hi guys,
a question for you Excel VBA experts. I wrote the following function
which applies formatting to a chart:
Function FormatAxes(Optional SheetName As String, Optional ChartName
As String, _
Optional IsEmbedded As Boolean, _
Optional Xmin, Optional Xmax, Optional Ymin, Optional Ymax, Optional
XMinorUnit, _
Optional XMajorUnit, Optional YMinorUnit, Optional YMajorUnit)
Dim xlChart As Chart
If SheetName = vbNullString Then SheetName = ActiveSheet.Name
If ChartName = vbNullString Then ChartName = ActiveChart.Name
If IsEmbedded Then
Set xlChart = Worksheets(SheetName).ChartObjects
(ChartName).Chart
Else
Set xlChart = Charts(ChartName)
End If
....
End Function
As you can see, i tried to wrote it in such a way that the code would
work also if the sheet name and chart name are not given in input: in
that case, the code usese the active sheet and active chart. Then I
realized that such a code would work only on embedded charts, so I
added the IsEmbedded optional parameter, which tells the code if the
chart is embedded or not. However, I'd really prefer the code to
determine by itself if the chart is embedded or not, rather than
relying on the user to supply the correct value for the IsEmbedded
optional parameter. Could you please help me do this? Thank you very
much,
Best Regards
Sergio Rossi
ps if anybody is interested in the full code of the function, and/or
its goal, feel free to ask
a question for you Excel VBA experts. I wrote the following function
which applies formatting to a chart:
Function FormatAxes(Optional SheetName As String, Optional ChartName
As String, _
Optional IsEmbedded As Boolean, _
Optional Xmin, Optional Xmax, Optional Ymin, Optional Ymax, Optional
XMinorUnit, _
Optional XMajorUnit, Optional YMinorUnit, Optional YMajorUnit)
Dim xlChart As Chart
If SheetName = vbNullString Then SheetName = ActiveSheet.Name
If ChartName = vbNullString Then ChartName = ActiveChart.Name
If IsEmbedded Then
Set xlChart = Worksheets(SheetName).ChartObjects
(ChartName).Chart
Else
Set xlChart = Charts(ChartName)
End If
....
End Function
As you can see, i tried to wrote it in such a way that the code would
work also if the sheet name and chart name are not given in input: in
that case, the code usese the active sheet and active chart. Then I
realized that such a code would work only on embedded charts, so I
added the IsEmbedded optional parameter, which tells the code if the
chart is embedded or not. However, I'd really prefer the code to
determine by itself if the chart is embedded or not, rather than
relying on the user to supply the correct value for the IsEmbedded
optional parameter. Could you please help me do this? Thank you very
much,
Best Regards
Sergio Rossi
ps if anybody is interested in the full code of the function, and/or
its goal, feel free to ask