| 
    
     |  | ▼もも さん: 
 >Sub chartsmente()
 >
 >Dim mySht As Worksheet
 >Dim i As Integer
 >Dim c As Integer
 >  i = 1
 >  C = 1
 > For Each mySht In Worksheets
 >  If mySht.Name <> "基本データ" Then
 >   mySht.Select
 >
 >   Do While Cells(3 + i, "O").Value <> ""
 >    If mySht.Cells(3 + i, "O").Value > Cells(3 + i, "P").Value Then
 >     Charts(c).Select
 >     ActiveChart.SeriesCollection(1).Points(i).Select
 >     With Selection.Interior
 >      .ColorIndex = 3
 >     End With
 >    End If
 >    i = i + 1
 >   Loop
 >  End If
 >  C = C + 1
 > Next
 >End Sub
 
 禰宜と申します。
 
 >シートが変わるたびに、変数iが「1」から始まるようにする
 
 シートが変わるということは、
 >For Each mySht In Worksheets でmyShtが参照する値が変わった時
 ということでしょうから、
 変数iの初期化をFor文の中に入れてしまえば良いのではないでしょうか。
 
 Sub chartsmente()
 
 Dim mySht As Worksheet
 Dim i As Integer
 Dim c As Integer
 C = 1
 For Each mySht In Worksheets
 i = 1
 If mySht.Name <> "基本データ" Then
 mySht.Select
 
 Do While Cells(3 + i, "O").Value <> ""
 If mySht.Cells(3 + i, "O").Value > Cells(3 + i, "P").Value Then
 Charts(c).Select
 ActiveChart.SeriesCollection(1).Points(i).Select
 With Selection.Interior
 .ColorIndex = 3
 End With
 End If
 i = i + 1
 Loop
 End If
 C = C + 1
 Next
 End Sub
 
 
 |  |