Sum of Variable Cells in a Column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

How to sum a variable no of cells in a column using VBA, I want the code to
sum up the cells on a certain condition of other cells such as IF(D10=""),
then add up all cells between N1 and N9, and so on IF D16="", then add up all
cells from N11 up to N15.
Can anybody help?
Regards.
 
if Range("D10").Value = "" then
mysum = Application.Sum(range("N1:N9"))
elseif Range("D16").Value = "" then
mysum = Application.Sum(range("N11:N15"))
else
mysum = 0
End if
 
Back
Top