federico460, 12/01/2021 19:38: =MATR.SOMMA.PRODOTTO(--(INDIRETTO("Tabella3[Flag]")="C")*(INDIRETTO("Tabella3[Data]")>=J$14)*(INDIRETTO("Tabella3[Data]")<=J$15)*((INDIRETTO("Tabella3[Entrata]"))-(INDIRETTO("Tabella3[Uscita]"))))
Private Sub CommandButton1_Click() If TextBox2 = "" Or ComboBox1 = "" Then MsgBox "Devi completare l'immissione delle date" Exit Sub End If 'add giorno dell'anno: attenzione cambia l'ordine di dateadd Dim X As Date Dim Y As Long X = Format(TextBox2, "dd/mm/yy") Y = ComboBox1 Z = DateAdd("d", Y, X) TextBox3 = Z Set sh1 = Sheets("Mov_Bank") ur = sh1.Cells(Rows.Count, 3).End(xlUp).Row For i = 6 To ur If sh1.Cells(i, 11) = "c" And sh1.Cells(i, 3) >= X And sh1.Cells(i, 3) <= Z Then TextBox5 = sh1.Cells(i, 10) - sh1.Cells(i, 9) End If Next i Set sh1 = Nothing End Sub
... For i = 6 To ur If TextBox5 = "" Then TextBox5 = 0 If sh1.Cells(i, 11) = "c" And sh1.Cells(i, 3) >= X And sh1.Cells(i, 3) <= Z Then TextBox5 = CDbl(TextBox5) + sh1.Cells(i, 10) - sh1.Cells(i, 9) End If Next i ...
Private Sub TextBox5_AfterUpdate() With Me.TextBox5 .Value = Format(.Text, "€ #,##0.00") End With End Sub
.... For i = 6 To ur If TextBox5 = "" Then TextBox5 = 0 If sh1.Cells(i, 11) = "c" And sh1.Cells(i, 3) >= X And sh1.Cells(i, 3) <= Z Then TextBox5 = CDbl(TextBox5) + sh1.Cells(i, 10) - sh1.Cells(i, 9) End If Next i TextBox5 = "€. " & TextBox5 Set sh1 = Nothing End Sub
Marius44, 25/01/2021 07:01: Attento che prima di un nuovo calcolo la TextBox5 deve essere vuota.
Private Sub CommandButton2_Click() For i = 5 To 5 Me.Controls("TextBox" & i).Value = "" Next Call CommandButton1_Click End Sub
.... Next i TextBox5 = "€ #,##0.00" & TextBox5 .......
Sub ApriUFFlag() Sheets("Mov_Bank").Activate If Range("N4") <> FALSO Then UserForm1.Show End If
.... ur = sh1.Cells(Rows.Count, 3).End(xlUp).Row TextBox5.Value = "" For i = 6 To ur If TextBox5 = "" Then TextBox5 = 0 If sh1.Cells(i, 11) = "c" And sh1.Cells(i, 3) >= X And sh1.Cells(i, 3) <= Z Then TextBox5 = CDbl(TextBox5) + sh1.Cells(i, 10) - sh1.Cells(i, 9) End If Next i TextBox5 = "€." & Format(TextBox5, "#,###.00") Set sh1 = Nothing End Sub