Hi,
I have a VBA problem which i cannot solve: I have a 2D array with values and the values from some columns are the same while the amounts are different. In this case i want to sumif the amounts and display the rest of values once (as a single array element with the whole amount).
I attached the file and also posted my code bellow:
Thanks a lot !
End Sub
I have a VBA problem which i cannot solve: I have a 2D array with values and the values from some columns are the same while the amounts are different. In this case i want to sumif the amounts and display the rest of values once (as a single array element with the whole amount).
I attached the file and also posted my code bellow:
Code:
Sub Macro1()
lastrow = Sheet1.Range("E3").End(xlDown).Row
Dim array1() As Variant
Dim optiune As String
If Sheet1.OptionButton1.Value = True Then
optiune = "yes"
Else: optiune = "no"
End If
arrlen = Application.WorksheetFunction.CountIf(Sheet1.Range("H2:H" & lastrow), optiune)
ReDim array1(arrlen - 1, 3)
Sheet1.Range("K5:N100000").ClearContents
r = 0
For i = 1 To lastrow
If Sheet1.Cells(i, 8) = optiune Then
array1(r, 0) = Sheet1.Cells(i, 5) 'nr factura
array1(r, 1) = Sheet1.Cells(i, 6) 'client
array1(r, 2) = Sheet1.Cells(i, 4) 'intarziere
array1(r, 3) = Sheet1.Cells(i, 7) 'suma
r = r + 1
End If
Next i
Sheet1.Range("K5" & ":" & "N" & arrlen + 4) = array1
Thanks a lot !
End Sub