0
I am trying to sum up all the numbers of each row and column. I tried to do as below, but it is not working.
ranger .ClearContents
For n = 1 To 10
For Z = 1 To 10
Cells(Z, n) = Int(100 * Rnd())
k = Cells(n, Z)
If Int(k / 2) - k / 2 = 0 Then
pares = pares + 1
Else
Impares = Impares + 1
End If
If k = 0 Then Zeros = Zeros + 1
If k > 10 Then MaioresQuedez = MaioresQuedez + 1
Cells(12, 2) = pares & " números Pares"
Cells(14, 2) = Impares & " números Ímpares"
Cells(16, 2) = Zeros & " números Zero"
Cells(18, 2) = MaioresQuedez & " números maiores do que 10"
next z
next n
Can someone help me? Thank you.
Wouldn’t k = Cells(Z,n) ?
– Reginaldo Rigo
is correct like this, I just want to know which command to use to add each row and column.
– luana
See if I get it. You start with a clean sheet. Then you enter a loop and start assigning random values to columns. Assigns a value to cell Z, n. In the next line you assign to variable K the contents of cell n, Z which is currently empty. That’s correct that?
– Reginaldo Rigo
I already edited there, I should ask you another question!
– luana
Luana, you are opening several questions very similar or very close. Please don’t do this. Even though you may have different doubts, simply pasting the same code doesn’t help. If you haven’t done it yet, do the [tour] and mainly read [Ask].
– Luiz Vieira
Another thing: if you want to add an interval (range), why not do it directly on the spreadsheet (selecting cells or using the function
SUM
)? By the way, even if you need implement something in Excel, if you have the range you can also use the function in the code (see that link).– Luiz Vieira