Results 1 to 4 of 4

Axes formatting XY graph

Threaded View

  1. #2
    Forum Contributor
    Join Date
    08-11-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    149

    Re: Axes formatting XY graph

    I can only think to do it w/ macros attached to the drop downs:

    1) in your graph go into "format axis" and on "number" tab, check "linked to source". Then add a macro like this to your date/week drop down:
    If Range("D30") = 1 Then
        Range("B36:B60").Select
        Selection.NumberFormat = "m/d/y"
    ElseIf Range("D30") = 2 Then
        Range("B36:B60").Select
        Selection.NumberFormat = "#"
    End If
    2) Add a macro like this to your city drop down:
    ActiveSheet.ChartObjects("Chart 3").Activate
    If Range("B30") = 1 Then
        ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B36:C60"), PlotBy _
            :=xlColumns
    ElseIf Range("B30") = 2 Then
        ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B36:C60"), PlotBy _
            :=xlColumns
    ElseIf Range("B30") = 3 Then
        ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B36:C60"), PlotBy _
            :=xlColumns
    ElseIf Range("B30") = 4 Then
        ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B36:C53"), PlotBy _
            :=xlColumns
    ElseIf Range("B30") = 5 Then
        ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B36:C52"), PlotBy _
            :=xlColumns
    End If
    Note that you could make the ranges dynamic but that's a bit more complicated. You can probably search on methods for setting dynamic ranges in macros if you want to go that route.

    Also note that certain elements will change if you implement this in another spreadsheet (ie, the chart won't always be "Chart 3", etc).

    (colors added for emphasis only)
    Last edited by Andy Pope; 08-12-2009 at 04:32 AM. Reason: code tags added

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1