Last active
December 17, 2015 09:29
-
-
Save stevehenderson/5587589 to your computer and use it in GitHub Desktop.
VBA Code to sum Range on a specified given sheetName and the coordinates of upper left and lower range corners.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'SumRangeOnSheet(sheetName, r0, c0, r1, c1 As Integer) | |
' | |
'Returns the sum of a range specied by UL point (r0, c0) and LR cell (r1,c0) | |
'on a worksheet specified by sheetName | |
' | |
Public Function SumRangeOnSheet(sheetName As String, r0 As Integer, c0 As Integer, r1 As Integer, c1 As Integer) | |
Dim aRange As Range | |
Set aRange = ActiveWorkbook.Sheets(sheetName).Range(ActiveWorkbook.Sheets(sheetName).Cells(r0, c0), ActiveWorkbook.Sheets(sheetName).Cells(lastRow, c0)) | |
SumRangeOnSheet = Application.WorksheetFunction.Sum(aRange) | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment