Option Explicit
Sub 平均合計を書き出す()
Dim sum, ave, i As Long
Dim gg, mmm, all As String
Dim MaxRow As Long
MaxRow = Range("A1").SpecialCells(xlLastCell).Row
For i = 2 To MaxRow
gg = "G" & i
mmm = "M" & i
all = gg & ":" & mmm
ave = WorksheetFunction.Average(Range(all)) '平均値
' sum = WorksheetFunction.sum(Range(all)) '合計
Range("N" & i) = ave
Next i
End Sub
Sub 変更をして書き出す()
Dim i, j As Long
Dim sum, gg, mmm, all, ave ' As String
Dim MaxRow, MaxColumn 'As Long
Dim strData As Long
MaxRow = Range("A1").SpecialCells(xlLastCell).Row
MaxColumn = Range("A1").SpecialCells(xlLastCell).Column
ReDim dall(MaxRow, MaxColumn) 'As Long
'データ開始行を入力
strData = Application.InputBox("データ行は" & vbLf & "(必須入力)", "データ行は", "2")
For j = strData To MaxRow
For i = 1 To MaxColumn
dall(j, i) = Cells(j, i)
If i = 7 Then
dall(j, i) = dall(j, i) + "1000"
ElseIf dall(j, i) = "A1019" Then 'セル内に"A1019"があったら
dall(j, i) = dall(j, i) & "ggg" '"A1019"に"ggg"を付ける
ElseIf i = 10 Then
dall(j, i) = dall(j, i) & "C"
End If
Next i
Next j
Cells(1, MaxColumn + 1).Resize(MaxRow + 1, MaxColumn + 1).Value = dall
' Range("S1").Resize(MaxRow + 1, MaxColumn + 1).Value = dall
End Sub