ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sum a salary column using macro (https://www.excelbanter.com/excel-programming/313733-sum-salary-column-using-macro.html)

tango

sum a salary column using macro
 
dear all, infact i need very simple coding but i still failed
i have this statement to count the total record to sum

lastrow = Range("C" & Rows.Count).End(xlUp).Row

now i just couldn't find a way to sum up salary column

something like this :

i know this is incorrect but i want something like this so can pass
the value to variable totalsum

totalsum = sum(range("e2:e" & lastrow))

Ivan F Moala[_27_]

sum a salary column using macro
 

Hi Tango, try something like

totalsum = Application.WorksheetFunction.Sum(Range("e2:e" & lastrow))

Have a look @ the help files for WorksheetFunctio

--
Ivan F Moal

-----------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...nfo&userid=195
View this thread: http://www.excelforum.com/showthread.php?threadid=26978


Don Guillett[_4_]

sum a salary column using macro
 
You almost got it. Just add application. before the sum

lastrow = cells(Rows.Count,3).End(xlUp).Row
totalsum =application.sum(range("e2:e" & lastrow))
--
Don Guillett
SalesAid Software

"tango" wrote in message
om...
dear all, infact i need very simple coding but i still failed
i have this statement to count the total record to sum

lastrow = Range("C" & Rows.Count).End(xlUp).Row

now i just couldn't find a way to sum up salary column

something like this :

i know this is incorrect but i want something like this so can pass
the value to variable totalsum

totalsum = sum(range("e2:e" & lastrow))





All times are GMT +1. The time now is 11:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com