ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to sum a column using vb (https://www.excelbanter.com/excel-programming/337506-how-sum-column-using-vbulletin.html)

smason

how to sum a column using vb
 
i have two columns in excel the first column contains some cells with Y (for
yes) in them and N (for no) the second column contains a financial amount
i.e. £5.00 next to each letter (Y or N)

i want to create a cmd button which contains an 'if' statement to sum all
the financial cells where the cells next to it contains "Y"

i.e.

column 1 Column 2
y £5
y £5
n £5

sum = £10.00


Jean-Yves[_2_]

how to sum a column using vb
 
Hi,

Use sumIf
SUMIF(range to evaluate,criteria,sum_range)

Application.WorksheetFunction.SumIf(Columns("A"), "Y", Columns("B"))

Regards

JY



"smason" wrote in message
...
i have two columns in excel the first column contains some cells with Y

(for
yes) in them and N (for no) the second column contains a financial amount
i.e. £5.00 next to each letter (Y or N)

i want to create a cmd button which contains an 'if' statement to sum all
the financial cells where the cells next to it contains "Y"

i.e.

column 1 Column 2
y £5
y £5
n £5

sum = £10.00





All times are GMT +1. The time now is 06:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com