G
G
gary0002020-06-10 22:38:47
Visual Basic
gary000, 2020-06-10 22:38:47

How to calculate the sum of the negative elements of an array?

Form the elements of the array according to the rule хi=sin(2i)-cos3 (i). Display its elements in column A. Calculate the sum of negative array elements. Display negative elements in a separate column.

Please help me calculate the sum of the negative elements of the array. Display negative elements in a separate column.

Private Sub calc_Click()
Dim y As Double
Dim i, k, n As Integer
For i = 2 To 11
y(i) = ("Sin * (2 * x) - Cos ^ 3 * x")
Cells(i + 1, 1) = x(i)
Next i
Min = x(1)
For i = 2 To 11
If

End If
Next i


End Sub

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Korben5E, 2020-06-11
@Korben5E

=SUMIF
=SUMIFS

A
anthony_marrey, 2020-06-23
@anthony_marrey

Dim Counter as Double
Dim cellNum, Cycle as Integer
cellNum = 1 
for Cycle = 0 to UBound(y)
    if y(Cycle).Value < 0 then 
        Cells(2,cellNum).Value = y(Cycle).Value
        cellNum = cellNum + 1 
        Counter = Counter + y(Cycle).value
     End if
next Cycle

The sum of all negative elements is recorded in the Counter, but you did not write what to do with it in the topic)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question