Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA to check if charttype is 3D

Posted on 2011-09-05
4
Medium Priority
?
420 Views
Last Modified: 2012-05-12
Hi Experts

I want to create a macro that checks if the chart a user has created is in 3D - I know there is a chartype property of chart, but this returns a number, does anyone have a list of numbers or is there a simpler way  -
currently I have

If InStr(UCase(mcht.ChartType), "3D") > 0 Then
       
            MsgBox "3D"
        End If
       
but as the charttpe is a number its not working, when selecting a charttype I can type in text
0
Comment
Question by:MrDavidThorn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:CSLARSEN
ID: 36485093
Hi
You can check for the number in chart type.

Check a list of chartypes, e.g. http://it.toolbox.com/wiki/index.php/EXCEL_Chart_Type_Enumeration
Another more complete but also less elegant would be to insert all 3D numbers in an array to validate the selected charttype against.
However from my point of view you are not using a poor proxy for 3D identification.
Cheers
cslarsen
0
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 36485124
Here is a function that incorporates the numbers suggested by CSLARSEN. It returns TRUE if the ChartType is one of the 3D types. Install it in a regular module, or incorporate the logic in your sub.

Function IsChart3D(co As ChartObject) As Boolean
Select Case co.Chart.ChartType
Case -4102 To -4100, -4098, 54 To 56, 60 To 62, 78 To 79
    IsChart3D = True
End Select
End Function

Open in new window

0
 
LVL 15

Expert Comment

by:CSLARSEN
ID: 36485406
Nice one byundt
learned the compact array/case part
thx carsten
0
 

Author Closing Comment

by:MrDavidThorn
ID: 36485466
thanks guys
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question