###前提・実現したいこと
上下A列を比較し、同じであればA列に紐づくB列の小計を累計しC列に出力出来るようにしたいです。
*写真参照お願いします。
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
エラーメッセージ
###該当のソースコード```
Sub macro1()
Dim color As Integer Dim flg As Integer Dim row As Long Dim i As Long Dim p_row_value As String Dim n_row_value As String Dim s_row As Long Dim e_row As Long p_row_value = "" n_row_value = "" color = 0 flg = 0 For row = 1 To Cells(Rows.Count, 1).End(xlUp).row n_row_value = Cells(row, 1).Value If n_row_value = p_row_value Then If flg = 0 Then color = (color + 1) Mod 2 s_row = row - 1 End If flg = 1 Cells(row, 3) = Cells(row - 1, 2) + Cells(row, 2) Cells(row - 1, 1).Interior.color = f_color(color) Cells(row, 1).Interior.color = f_color(color) Else flg = 0 End If p_row_value = n_row_value Next row
End Sub
Function f_color(flg As Integer) As Long
If flg = 0 Then
f_color = RGB(255, 0, 0)
Else
f_color = RGB(255, 255, 0)
End If
End Function
###試したこと
試して見るもののうまく行かず。。。
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な
テンプレートの元から記述してある例文部分は削除してください。コードは、コードタグで囲ってください。コードを選択して、</>ボタンをおせば自動でタグが挿入されます。
回答2件
あなたの回答
tips
プレビュー