Posts by nikita333

    I need to write a macro that would create a graph that shows a difference between two data series. Mainly, I need to figure out which chart type is best suited for such a task, then I can probably figure out VBA code for it myself, though, any help is appreciated.

    Actually, Andy, I'm still having problems with the original task I was trying to accomplish. What would the VBA code for something like this be:



    Nikita

    Hi, Andy


    Here's an example of one of my tables:


    Code
    1	1	10000	245	122	0	0	0
    1	2	10000	246	246	0	0	1
    1	4	10000	244	488	0	0	0
    1	8	10000	238	952	0	0	1
    1	16	10000	239	1912	0	0	1
    1	32	10000	233	3728	0	0	0
    1	64	10000	217	6944	0	0	1
    1	128	10000	193	12352	0	0	1


    I graph 4th-D column (y-axis) against 2nd-B column (x-axis) and want to set the bars to red when the value in the last (H) column is 1, and keep them default color otherwise. I hope I'm making sense, please let me know if it's unclear.


    Thanks in advance

    Hi,


    I have a pretty long VBA Macro where I create a bunch of charts and based on the values in certain cells set column colors (xlColumnClustered graphs). For some reason when I do that the chart legend gets modified, it now has X axis values in it instead of the original title. Here's an exerpt from my code:


    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=Sheets("latestResults").Range("D415:D422") _
    , PlotBy:=xlColumns
    ActiveChart.SeriesCollection(1).XValues = "=latestResults!R415C2:R422C2"
    ActiveChart.SeriesCollection(1).Name = "=latestResults!R406C1:R413C1"
    ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="ChartName"
    With ActiveChart
    .HasTitle = False
    .Axes(xlCategory, xlPrimary).HasTitle = True
    .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "xaxis"
    .Axes(xlValue, xlPrimary).HasTitle = True
    .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "yaxis"
    End With
    ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
    ActiveChart.Legend.Select
    Selection.Width = 203
    Selection.Left = 379
    Selection.Width = 272
    Selection.Left = 339
    Selection.Width = 312
    Selection.Left = 316
    Selection.Width = 334
    Selection.Left = 342
    Selection.Top = 1
    Dim cellRange As Range
    Set cellRange = Sheets("latestResults").Range("H415:H422")
    Call CheckForErrors(cellRange)


    and here's the CheckForErrors Sub:


    Sub CheckForErrors(myRange)
    Dim cel As Range
    Dim index As Integer
    index = 1
    For Each cel In myRange
    If cel.Value = 1 Then
    ActiveChart.SeriesCollection(1).Points(index).Interior.ColorIndex = 3
    End If
    index = index + 1
    Next cel
    End Sub


    Any help you guys can give me I will really appreciate.


    Thanks,
    Nikita