SUMPRODUCT((MOD(B2:G2,2)<>0)+0)

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
986
Office Version
  1. 2010
Platform
  1. Windows
Hi. First my excel have a problem, meaning I am NOT able to upload the xl2bb, for this reazon I am NOT loading a partial sheet here, sorry, sorry.
OK, now my question today is:
My data is a ►"DYNAMIC"◄ array at B2:G2800
the computations I am trying is the formulas SUMPRODUCT((mod(B2:G2,2)=0)+0) , and SUMPRODUCT((MOD(B2:G2,2)<>0)+0)
and display the results on M and N
what I did so far is try a normal way (the easy one first)
VBA Code:
Sub even_odds()
         Sheet5.Range("M2").Formula = "=SUMPRODUCT((mod(B2:G2,2)=0)+0)"
         Sheet5.Range("N2").Formula = "=SUMPRODUCT((MOD(B2:G2,2)<>0)+0)"
End Sub
with this the result are on M and N and of course only two cells with right answer. obvious I need a loop to read the whole array and populate column M/N
so my second try with a loop is:
VBA Code:
Sub Trial_error()
Dim monte As Long, carlo As Long
monte = 2
         For carlo = 5 To Cells(Rows.Count, "B").End(xlUp).Row
                     Sheet5.Range("M" & carlo).FormulaR1C1 = "=sumproduct((mod(R2C" & monte & ":R2C" & monte & ",R2C1:R2C1)=0)+0)"
                     Sheet5.Range("N" & carlo).FormulaR1C1 = "=sumproduct((mod(R2C" & monte & ":R2C" & monte & ",R2C1:R2C1)<>0)+0)"
         monte = monte + 1
         Next carlo
End Sub
the results with this loop is zeros and ones only (wrong results)
and remember I already explain I am not able to use xl2bb. so the image here maybe help. (sorry)
1590456283344.png

I am doing my best.
Thank you for reading this
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Maybe
VBA Code:
Sub Test()
    Sheet5.Range("M2:M" & Cells(Rows.Count, "B").End(xlUp).Row).FormulaR1C1 = "=SUMPRODUCT(--ISODD(+RC[-11]:RC[-6]))"
    Sheet5.Range("N2:N" & Cells(Rows.Count, "B").End(xlUp).Row).FormulaR1C1 = "=SUMPRODUCT(--ISEVEN(+RC[-12]:RC[-7]))"
End Sub
 
Upvote 0
Tetra201 Thank you Sir. Work perfect. I really appreciate your Help.
Hope the best for you.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top