View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.charting
Jon Peltier
 
Posts: n/a
Default How do I offer ChartType options?

Here is another point, which may not be the issue here, but would definitely
cause problems in bubble or stock charts. It is more reliable in VBA to set
a chart's source data range first, then assign a chart type. If the chart
does not have the correct data to support the chart type, you get an error.
Even if you're using a recorded macro, it will fail for this reason.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


"Greg Wilson" wrote in message
...
Hi David,

All of the following comments are based on minimal testing and several
assumptions.

I assume that the spelling error in "Dim CharttNme" (note double t) only
exists in your post. Your post executes the OB1 click event on UF
initialization:

< Private Sub UserForm_Initialize()
< OptionButton1_Click
< End Sub

This doesn't change OB1's value to True (contrary to logic) and therefore
the CharttType routine, assuming neither OB1 nor OB2 are defaulted to True
through Properties, fails to set a value for ChartNme and its value is
"Empty" when GraphTables is called:

< Private Sub CharttType()
< If OptionButton1.Value = True Then
< chartNme = xlXYScatterSmooth 'Spelling corrected
< ElseIf OptionButton2.Value = True Then
< chartNme = xlColumnClustered
< End If
< Call GraphTables
< End Sub

I assume, by executing the Click event for OB1 on initialization, you want
OB1 to default to True and to import its associated graph. I would instead
set its value to True through Properties (right-click OB1 select
Properties
set Value to True) and directly execute the CharttType routine on UF

initialization. However, setting OB1 to True directly on UF initialization
instead of executing its click event will also achieve the desired
objective:

Private Sub UserForm_Initialize()
OptionButton1 = True 'This works
End Sub

I reiterate my recommendation for Stephen Bullen's PastePicture.zip.
You're
driving a Hyundai Pony and a Lexus is free. Also be carefull using Kill.
Files deleted this way don't go to the Recycle Bin, they're just history.
Not
to imply I would do it any different (get rid of fname).

Regards,
Greg




"davidm" wrote:


Greg,

Many thanks. The flaws you picked were inadvertent and resulted from
hurried (over)editing. But even working with the original codes which
had none of the blemishes, the Type Mismatch error was generated.

Your approach of passing the ChartType as arguments from subordinate
subs worked well. But I am still a bit mystifed by the failure of the
GraphTables code to handle the ChartNme (globally-declared) variable.
arguments.

While you have solved my primary problem, any thoughts on why my method
failed would be appreciated.

David


--
davidm
------------------------------------------------------------------------
davidm's Profile:
http://www.excelforum.com/member.php...o&userid=20645
View this thread:
http://www.excelforum.com/showthread...hreadid=496334