ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   generate Odd row numbers in VBA (https://www.excelbanter.com/excel-programming/393907-generate-odd-row-numbers-vba.html)

Khoshravan

generate Odd row numbers in VBA
 
I want to add cells with odd row numbers in a column.
How can I generate odd row numbers in VBA?
--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan

Stephane Quenson

generate Odd row numbers in VBA
 
Why a formula like =SUMPRODUCT(A1:A11,MOD(ROW(A1:A11),2)) which will add the
cells A1, A3, A5, A7, A9 and A11?

If you want to do it in VBA, use a loop with a step equals to 2:
Total = 0
For iRow = 1 To 11 Step 2
Total = Total + Cells(iRow, 1)
Next iRow


All times are GMT +1. The time now is 06:14 PM.

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