NocoffeeNoWorkee
New Member
- Joined
- Apr 28, 2016
- Messages
- 12
How can I put an average of the last row in the first empty column of the same row?
Here is what I tried:
[TABLE="class: outer_border, width: 800"]
<tbody>[TR]
[TD]Sub LastRowAve()
lastrow = ThisWorkbook.Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
lColumn = ThisWorkbook.Sheets("sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
ThisWorkbook.Sheets("sheet1").Range(lColumn + 1 & lastrow) = Application.WorksheetFunction.Average(ThisWorkbook.Sheets("sheet1").Range("A" & lastrow:lColumn&lastrow))
End Sub
[/TD]
[/TR]
</tbody>[/TABLE]
Theres a problem with the list seperator in Range.
Here is what I tried:
[TABLE="class: outer_border, width: 800"]
<tbody>[TR]
[TD]Sub LastRowAve()
lastrow = ThisWorkbook.Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row
lColumn = ThisWorkbook.Sheets("sheet1").Cells(1, Columns.Count).End(xlToLeft).Column
ThisWorkbook.Sheets("sheet1").Range(lColumn + 1 & lastrow) = Application.WorksheetFunction.Average(ThisWorkbook.Sheets("sheet1").Range("A" & lastrow:lColumn&lastrow))
End Sub
[/TD]
[/TR]
</tbody>[/TABLE]
Theres a problem with the list seperator in Range.