Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Raynard Fischer   on Mar 13 In MS Office Category.

  
Question Answered By: Grady Stewart   on Mar 13

to see the result of Debug.print use the immediate window:
View, Immediate Window or Ctrl + G

A modification to handle when there are <20 rows:

Sub SumLast20RowsInColA()
Dim lrow As Long, ans As Long, lastEntries As Integer
lrow = Cells(Rows.Count, 1).End(xlUp).Row
lastEntries = 20
If lrow < lastEntries Then lastEntries = lrow - 1
ans = Application.WorksheetFunction.Sum(Cells(lrow - lastEntries +
1, 1).Resize(lastEntries, 1))
Debug.Print ans
End Sub

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on getting the sum of the last 20 cells Or get search suggestion and latest updates.


Tagged: