| 
    
     |  | こんにちは。 このホームページを利用させてもらうようになり、皆さまのおかげで少しずつですがマクロについて理解できるようになってきました。
 またつまづいてしまったので、どなたかご教授お願いできますでしょうか。
 
 下記のように、ひとつのブックに複数のシートがあり、それぞれのシートのK29:K32、K33:K36の値をY軸にとり2本の棒グラフをひとつのグラフに示しています。K29:K32などのセルには
 場合によっては#NUMが入っていることがあり、そのままマクロでかかせると#NUM=0とみなしてグラフができ上がります。
 #NUMのところは値がないものとして、グラフには付け加えたくないのです。(例えば#NUMが存在する場合、K29とK31で#NUMというようにひとつ飛びになったりすることはありません。
 K30からK32までが全て#NUM、K31とK32が#NUMというようになります。)
 こういった場合、どのような条件をコードのどこにつければよいのでしょうか?
 教えてください。よろしくお願いいたします。
 
 Sub グラフ6作成()
 Dim i As Integer
 For i = 1 To 63
 Sheets("PL000" & Format(i, "00")).Select
 
 Charts.Add
 ActiveChart.ChartType = xlLineMarkers
 ActiveChart.SetSourceData Source:=Sheets("PL000" & Format(i, "00")).Range("K29:K32"), PlotBy _
 :=xlColumns
 ActiveChart.SeriesCollection.NewSeries
 ActiveChart.SeriesCollection(1).XValues = "=(PL000" & Format(i, "00") & "!R29C2:R32C2)"
 ActiveChart.SeriesCollection(1).Name = "=""ACA11"""
 ActiveChart.SeriesCollection(2).XValues = "=(PL000" & Format(i, "00") & "!R29C2:R32C2)"
 ActiveChart.SeriesCollection(2).Values = "=(PL000" & Format(i, "00") & "!R33C11:R36C11)"
 ActiveChart.SeriesCollection(2).Name = "=""IM-9"""
 ActiveChart.Location Where:=xlLocationAsObject, Name:="PL000" & Format(i, "00")
 With ActiveChart
 .HasTitle = True
 .ChartTitle.Text = "=PL000" & Format(i, "00") & "!R3C7"
 .Axes(xlCategory, xlPrimary).HasTitle = True
 .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
 "added IgG (ug/mL)"
 .Axes(xlValue, xlPrimary).HasTitle = True
 .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "bound IgG (ug/mL)"
 End With
 ActiveChart.HasLegend = True
 ActiveChart.Legend.Select
 Selection.Position = xlBottom
 Selection.AutoScaleFont = False
 ActiveChart.ChartArea.Select
 Selection.AutoScaleFont = False
 With Selection.Font
 .Name = "MS ゴシック"
 .FontStyle = "標準"
 .Size = 7
 .Strikethrough = False
 .Superscript = False
 .Subscript = False
 .OutlineFont = False
 .Shadow = False
 .Underline = xlUnderlineStyleNone
 .ColorIndex = xlAutomatic
 .Background = xlAutomatic
 End With
 ActiveChart.Axes(xlCategory).Select
 With ActiveChart.Axes(xlCategory)
 .CrossesAt = 1
 .TickLabelSpacing = 1
 .TickMarkSpacing = 1
 .AxisBetweenCategories = False
 .ReversePlotOrder = False
 End With
 ActiveChart.SeriesCollection(1).Select
 With Selection.Border
 .Weight = xlThin
 .LineStyle = xlAutomatic
 End With
 With Selection
 .MarkerBackgroundColorIndex = xlAutomatic
 .MarkerForegroundColorIndex = xlAutomatic
 .MarkerStyle = xlDiamond
 .Smooth = False
 .MarkerSize = 3
 .Shadow = False
 End With
 ActiveChart.SeriesCollection(1).ErrorBar Direction:=xlY, Include:=xlBoth, _
 Type:=xlCustom, Amount:="=(PL000" & Format(i, "00") & "!R29C28:R32C28)", MinusValues:= _
 "=(PL000" & Format(i, "00") & "!R29C28:R32C28)"
 ActiveChart.SeriesCollection(1).ErrorBars.Select
 With Selection.Border
 .LineStyle = xlContinuous
 .ColorIndex = 5
 .Weight = xlThin
 End With
 Selection.EndStyle = xlCap
 ActiveChart.SeriesCollection(2).Select
 With Selection.Border
 .Weight = xlThin
 .LineStyle = xlAutomatic
 End With
 With Selection
 .MarkerBackgroundColorIndex = xlAutomatic
 .MarkerForegroundColorIndex = xlAutomatic
 .MarkerStyle = xlSquare
 .Smooth = False
 .MarkerSize = 3
 .Shadow = False
 End With
 ActiveChart.SeriesCollection(2).ErrorBar Direction:=xlY, Include:=xlBoth, _
 Type:=xlCustom, Amount:="=(PL000" & Format(i, "00") & "!R33C28:R36C28)", MinusValues:= _
 "=(PL000" & Format(i, "00") & "!R33C28:R36C28)"
 ActiveChart.SeriesCollection(2).ErrorBars.Select
 With Selection.Border
 .LineStyle = xlContinuous
 .ColorIndex = 26
 .Weight = xlThin
 End With
 Selection.EndStyle = xlCap
 ActiveChart.ChartArea.Select
 ActiveChart.Axes(xlCategory).Select
 With ActiveChart.Axes(xlCategory)
 .CrossesAt = 1
 .TickLabelSpacing = 1
 .TickMarkSpacing = 1
 .AxisBetweenCategories = False
 .ReversePlotOrder = False
 End With
 Next
 End Sub
 
 
 |  |