I have query using worksheet function in excel vba, I have written the code, but Its not getting the results, I am looking some particular columns to do sum and output should be on desired column, since I will be updating the data in same columns in dayin & dayout, below is the example and code which I prepared.
A1,B1,C1,D1,E1,F1 - ------ J1(sum of A1,c1,d1,f1)
A100,b100,c100,d100,e100,f100-------J100(sum of a100,c100,d100,f100)
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("J1:J" & lastrow).Formula = Application.WorksheetFunction.Sum(Range("a1:a" & lastrow), Range("c1:c" & lastrow), Range("d1:d" & lastrow), Range("f1:f" & lastrow))
I would request any one of you to help me correcting this code.
Thanks in advance.