| 
    
     |  | お世話になります。 
 下記のマクロを作ったのですが、コメントアウトしたところでエラーが発生してしまいます。
 しかもiに関してのForループが回った後です。なぜかわかりますか??
 
 
 Sub ネガポジ()
 
 Dim i As Integer ' 変数
 Dim score As Double
 Dim number As Double
 Dim j As Integer
 Dim m As Integer
 Dim s As Integer
 score = 0
 number = 0
 
 
 i = 2
 
 
 Rows(2).Insert ' 行を挿入
 Rows(3).Insert
 Do While Cells(1, i) <> ""
 Cells(2, i) = StrConv(Cells(1, i), vbKatakana) '単語をカタカナに変換
 Cells(3, i) = StrConv(Cells(1, i), vbHiragana) ' 単語を平仮名に変換
 i = i + 1
 
 Loop
 i = 3
 Rows(6).Insert
 Rows(7).Insert
 Rows(8).Insert
 Cells(6, 2).Value = "=VLOOKUP(B1,データベース!$A$1:$D$60000,4,False)" ' スコアの表示
 Cells(7, 2).Value = "=VLOOKUP(B2,データベース!$B$1:$D$60000,3,False)"
 Cells(8, 2).Value = "=VLOOKUP(B3,データベース!$B$1:$D$60000,3,False)"
 Do While Cells(1, i) <> ""
 Cells(6, i - 1).Copy Cells(6, i)
 Cells(7, i - 1).Copy Cells(7, i)
 Cells(8, i - 1).Copy Cells(8, i)
 i = i + 1
 Loop
 m = Cells(Rows.Count, "A").End(xlUp).Row
 s = Cells(9, Columns.Count).End(xlToLeft).Column
 For j = 9 To m
 score = 0
 number = 0
 For i = 2 To s
 If Cells(j, i).Value > 0 Then
 If Application.WorksheetFunction.IsError(Cells(6, i)) = False Then
 score = score + Cells(6, i).Value * Cells(j, i).Value
 number = number + Cells(j, i).Value
 ElseIf Application.WorksheetFunction.IsError(Cells(7, i)) = False Then
 score = score + Cells(7, i).Value * Cells(j, i).Value
 number = number + Cells(j, i).Value
 ElseIf Application.WorksheetFunction.IsError(Cells(8, i)) = False Then
 score = score + Cells(8, i).Value * Cells(j, i).Value
 number = number + Cells(j, i).Value
 Else
 End If
 End If
 Next i  'なぜかForループが終わったときにエラーを吐く。
 If number = 0 Then
 Cells(j, i).Value = 0
 Else
 MsgBox score / number
 Cells(j, i).Value = score / number
 End If
 Next j
 
 Cells(9, i - 1).Copy
 Cells(9, i).PasteSpecial
 Cells(9, i - 1).Value = ""
 Cells(8, i).Value = "ネガポジ分析結果"
 
 
 End Sub
 
 |  |