| 
    
     |  | こんにちは 
 最終データ行を取得するのは「年月日」の列で良いですか?
 
 このデータには「年月日」「1月」「合計」が無ければ処理しません。
 上記項目は同じ行にあること。
 
 ではお試しを。
 
 Sub Test_1()
 Dim Fi As Range, Ma As Variant
 Dim Ro As Long, Ad As String
 
 With ActiveSheet
 Set Fi = .Cells.Find("年月日", , xlValues, xlWhole)
 If Fi Is Nothing Then
 MsgBox "年月日がありません。", vbCritical
 Exit Sub
 End If
 Ro = .Cells(65536, Fi.Column).End(xlUp).Row
 Set Fi = Nothing
 Set Fi = .Cells.Find("1月", , xlValues, xlWhole)
 If Fi Is Nothing Then
 MsgBox "1月がありません。", vbCritical
 Exit Sub
 End If
 Ma = Application.Match("合計", .Rows(Fi.Row), 0)
 If IsError(Ma) Then
 MsgBox "合計がありません。", vbCritical
 Exit Sub
 End If
 Ad = .Range(.Cells(Fi.Row + 1, Fi.Column), .Cells(Fi.Row + 1, Ma - 1)).Address(0, 0)
 With .Range(.Cells(Fi.Row + 1, Fi.Column), .Cells(Ro, Fi.Column)).Offset(, Ma - Fi.Column)
 .Formula = "=SUM(" & Ad & ")"
 .Value = .Value
 End With
 End With
 
 End Sub
 
 |  |