sum a salary column using macro

  • Thread starter Thread starter tango
  • Start date Start date
T

tango

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))
 
Hi Tango, try something like

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

Have a look @ the help files for WorksheetFunctio
 
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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top