Determining Whether A Graph Is Second Or Third `

  • For some reason my thread title wasn't liked which originally read: "Determining Whether A Graph is 2d or 3d with an If or Case Function"



    Hi,


    I am running a simple macro that does a lot of formatting to the active graph but I need to include either an If or Case function that will determine whether it is 3d in which case a few different options will want to be executed.


    My question though is simply what is the syntax that may be able to determine whether a pre-made chart is 3D or not.


    Thanks for your help,


    Tim

  • Re: Determining Whether A Graph Is Second Or Third `


    hi,


    try this one:

    Code
    For i = ActiveSheet.ChartObjects.Count To 1 Step -1
    Select Case i = 3
    Case True
        MsgBox ActiveSheet.ChartObjects(i).Name 'yr code here
    End Select
    Next

    Cheers
    ___________
    Xlite :sheep:
    [st]All you need to learn VBA is an internet connection and Ozgrid.com[/st]

  • Re: Determining Whether A Graph Is Second Or Third `


    oops, i misunderstood.


    could you specify which 3D chart type/s you're using?

    Cheers
    ___________
    Xlite :sheep:
    [st]All you need to learn VBA is an internet connection and Ozgrid.com[/st]

  • Re: Determining Whether A Graph Is Second Or Third `


    Well it would actually quite like to work with lots, but I mean simply 3D in display, not 3D in terms of points plotted, so bar charts mainly, but maybe Pie charts or similar.


    The reason it is relevant is in terms of formatting the background colours etc... There are lots of graphs to be done and many many more in the future so it will be convenient to have a master macro that makes them all along the same style.


    Thanks,


    Tim

  • Re: Determining Whether A Graph Is Second Or Third `


    Quote from shmee150

    Well it would actually quite like to work with lots, but I mean simply 3D in display, not 3D in terms of points plotted, so bar charts mainly, but maybe Pie charts or similar.


    hmmm, thats a lot of ground to cover,
    but u can try running this code and take down which are 3D charts and do a select case based on that:

    Code
    For i = ActiveSheet.ChartObjects.Count To 1 Step -1
    MsgBox ActiveSheet.ChartObjects(i).Chart.ChartType
    Next

    Cheers
    ___________
    Xlite :sheep:
    [st]All you need to learn VBA is an internet connection and Ozgrid.com[/st]

  • Re: Determining Whether A Graph Is Second Or Third `


    I think that's probably the best way to do it; a select case based on all the common graph types that are going to be used individually and a simple error message if it's another type.


    Hmm, thanks for the advice.


    Tim

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!