+ Reply to Thread
Results 1 to 2 of 2

How to create a stock column chart with error bars?? (Both gender together)

Hybrid View

  1. #1
    Registered User
    Join Date
    10-22-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    43

    How to create a stock column chart with error bars?? (Both gender together)

    Hi

    I have a series of data and want to create a chart looking like this

    tmp0.jpg
    where it shows min/max on the error bars, quartile 1/3 on the box and median as a scatter plot. My data is a simple table

    tmp.jpg

    Here F = Female, M=Male and the chart should show all calculation for both gender together (I have another thread up where the gender are separated with the Title (How to create a stock column chart with error bars?? (Both gender separated))

    Please help me with a (pseudo) code, I have never used VBA for creating chart, and this is my first
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    10-22-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: How to create a stock column chart with error bars?? (Both gender together)

    Hi all, I was able to solve it in a way. Here is the code for anyone wanting to do a chart with boxes and error bars

    min = WorksheetFunction.min(Range("P2:P7"))
    maxtmp = WorksheetFunction.max(Range("P2:P7"))
    Q1tmp = WorksheetFunction.Quartile(Range("P2:P7"), 1)
    Q3tmp = WorksheetFunction.Quartile(Range("P2:P7"), 3)
    max = maxtmp - Q3tmp
    Q1 = Q1tmp - min
    Q3 = Q3tmp - Q1tmp
    whiskerp = maxtmp - Q3tmp
    whiskerm = Q1tmp - min
    
    With myChart.Chart
        With .SeriesCollection.NewSeries
            .Name = "Median"
            .Values = ws.Range("F9:F9") ' median
            .ChartType = xlXYScatter
            .MarkerStyle = 3
        End With
        With .SeriesCollection.NewSeries    'min
            .Name = "min"
            .Values = min
            .ChartType = xlColumnStacked
            .Format.Fill.Visible = msoFalse
        End With
        With .SeriesCollection.NewSeries    'Q1
            .Name = "Q1"
            .Values = Q1
            .ErrorBar Direction:=xlY, Include:=xlMinusValues, Type:=xlCustom, Amount:=whiskerp, MinusValues:=whiskerm
            .ChartType = xlColumnStacked
            .Format.Fill.Visible = msoFalse
        End With
        With .SeriesCollection.NewSeries    'Q3
            .Name = "Q3"
            .Values = Q3
            .ErrorBar Direction:=xlY, Include:=xlPlusValues, Type:=xlCustom, Amount:=whiskerp
            .ChartType = xlColumnStacked
        End With
    End With

+ Reply to Thread

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