#1 VBA - Excel Sum Function in VBA Code

preview_player
Показать описание
We create a VBA function called SumCode() that does the same thing the Sum Function does in excel to illustrate how functions work in VBA

Function SumCode(rng As Range)
sumx = 0
For Each cell In rng
sumx = sumx + cell.Value
Next

SumCode = sumx
End Function
Рекомендации по теме
Комментарии
Автор

hi sir, request you please write your code in description section so that we can copy and past and learn this code.

NIRAJKUMAR-fmvp
Автор

Dont know if you still follow this but...I am trying to run a function passing in a range BUT its running from a summary page for a data sheet range to pass into function. I cant seem to access the sheet within the range to know that it count from that sheet and not the current summary one !

I can set it and FORCE it to work by setting the sheet....but I would like it to take the datasheet!<range> that is passed through rather than c1:c10 ...do you know how ? I have assumed its still a range variable but maybe not ?

Thanks

Ed.

edmardell
Автор

Could you please provide the code for SUMIF & SUMIFS VBA Code

bala
welcome to shbcf.ru