Sum of Variable Cells in a Column

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.
 
T

Tom Ogilvy

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
 

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

Top