Dim Righe, Colonne
Dim Intervallo As Range
Private Sub cmdarchivia_Click()
Dim Unione As Range
Dim FinalRow As Long
Dim R As Long
Dim WsTo As Worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
txtfatturato = Format(txtfatturato, "#,#00.00")
Set WsTo = Worksheets("Archivio")
FinalRow = WsTo.Cells(WsTo.Rows.Count, 1).End(xlUp).Row
R = 2
R = FinalRow + 1
WsTo.Cells(R, 1) = txtcodice2.Value
WsTo.Cells(R, 2) = txtagente2.Value
WsTo.Cells(R, 3) = txtdivisione2.Value
WsTo.Cells(R, 4) = cbotipocontr2.Value
WsTo.Cells(R, 5) = DTPicker1.Value
WsTo.Cells(R, 6) = txtfatturato.Value
WsTo.Cells(R, 7) = txtcontratto.Value
WsTo.Cells(R, 8) = txtimpdoc.Value
WsTo.Cells(R, 9) = cbotipdoc.Value
WsTo.Cells(R, 10) = txtnumdoc.Value
WsTo.Cells(R, 11) = cbomod9.Value
WsTo.Cells(R, 12) = DTPicker2.Value
WsTo.Cells(R, 13) = txtnote2.Value
MsgBox "Creato Archivio"
txtcodice2.Value = ""
txtagente2.Value = ""
txtdivisione2.Value = ""
cbotipocontr2.Value = ""
DTPicker1.Value = Date
txtfatturato.Value = ""
txtcontratto.Value = ""
txtimpdoc.Value = ""
cbotipdoc.Value = ""
txtnumdoc.Value = ""
cbomod9.Value = ""
DTPicker2.Value = Date
txtnote2.Value = ""
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Private Sub cmdchiudi_Click()
Unload frmlivelli
End Sub
Private Sub ComboBox3_Change()
Dim Codice, Riga, Righe
Dim Intervallo As Range
Dim R As Integer
Dim Trovato As Boolean
Trovato = False
R = 1
Do Until Trovato = True Or R = 1000
If Range("A" & R) = ComboBox3.Value Or Range("B" & R) = ComboBox3.Value Or Range("C" & R) = ComboBox3.Value Then
txtcodice2.Text = Range("A" & R)
txtagente2.Text = Range("B" & R)
txtdivisione2.Text = Range("C" & R)
cbobuyer2.Value = Range("D" & R)
cboanno2.Value = Range("E" & R)
cbotipocontr2.Value = Range("F" & R)
txttipodoc2.Text = Range("G" & R)
cbomod.Value = Range("H" & R)
TextBox5.Text = Range("I" & R)
cboscad.Value = Range("J" & R)
cbomod2.Value = Range("K" & R)
TextBox6.Text = Range("L" & R)
cboscad2.Value = Range("M" & R)
cbomod3.Value = Range("N" & R)
TextBox7.Text = Range("O" & R)
cboscad3.Value = Range("P" & R)
cbomod4.Value = Range("Q" & R)
TextBox8.Text = Range("R" & R)
cboscad4.Value = Range("S" & R)
cbomod5.Value = Range("T" & R)
TextBox9.Text = Range("U" & R)
cboscad5.Value = Range("V" & R)
cbomod7.Value = Range("W" & R)
txtart2.Text = Range("X" & R)
cboscad7.Value = Range("Y" & R)
cbomod8.Value = Range("Z" & R)
txtbrand2.Text = Range("AA" & R)
cboscad8.Value = Range("AB" & R)
txttotcontr2.Text = Range("AC" & R)
cbomodificato2.Value = Range("AD" & R)
cbopubblicato2.Value = Range("AE" & R)
txtnote2.Text = Range("AF" & R)
txtfattm.Text = Range("AG" & R)
txtfattm = Format(txtfattm, "#,#00.00")
txtfattb.Text = Range("AH" & R)
txtfattb = Format(txtfattb, "#,#00.00")
txtfattt.Text = Range("AI" & R)
txtfattt = Format(txtfattt, "#,#00.00")
txtfatts.Text = Range("AJ" & R)
txtfatts = Format(txtfatts, "#,#00.00")
txtfatta.Text = Range("AK" & R)
txtfatta = Format(txtfatta, "#,#00.00")
Trovato = True
End If
R = R + 1
Loop
If Trovato = False Then
MsgBox "Divisione non in elenco"
ComboBox3.Value = ""
ComboBox3.SetFocus
End If
'Codice per riempimento combobox4
'Riempimento numero fattura
ComboBox4.Clear
Codice = ComboBox3.Text
With Intervallo
For Riga = 1 To Righe
If .Item(Riga, 1) = Codice Then
ComboBox4.AddItem (.Item(Riga, 2))
End If
Next
End With
End Sub
'Codice per riempimento combobox4
'Riempimento numero fattura
Private Sub ComboBox4_Change()
Dim Intervallo As Range
Dim Fattura, Riga, Codice
Fattura = ComboBox4.Text
Codice = ComboBox3.Text
With Intervallo
For Riga = 1 To Righe
If .Item(Riga, 10) = Fattura And .Item(Riga, 1) = Codice Then
DTPicker1 = .Item(Riga, 5)
txtfatturato = .Item(Riga, 6)
txtcontratto = .Item(Riga, 7)
txtimpdoc = .Item(Riga, 8)
cbotipdoc = .Item(Riga, 9)
txtnumdoc = .Item(Riga, 10)
cbomod9 = .Item(Riga, 11)
DTPicker2 = .Item(Riga, 12)
txtnote2 = .Item(Riga, 13)
End If
Next
End With
End Sub
Private Sub txtcontratto_Change()
If txtcontratto <> "" Then
txtimpdoc.Text = Format(CDbl(txtfatturato) * Val(txtcontratto) / 100, "#0.00")
Else
End If
End Sub
Private Sub txtfatturato_Change()
If txtfatturato <> "" Then
txtimpdoc.Text = Format(CDbl(txtfatturato) * Val(txtcontratto) / 100, "#0.00")
Else
End If
End Sub
Private Sub UserForm_Activate()
Dim Riga, Righe, Colonne, Codice
Dim Elenco As New Collection
Dim Intervallo As Range
cboscad9.AddItem "M"
cboscad9.AddItem "B"
cboscad9.AddItem "T"
cboscad9.AddItem "S"
cboscad9.AddItem "A"
cbomod9.AddItem "FP"
cbomod9.AddItem "FP1"
cbomod9.AddItem "NAP"
cbomod9.AddItem "NAP1"
cbotipdoc.AddItem "FT"
cbotipdoc.AddItem "NC"
DTPicker1.Value = Date
DTPicker2.Value = Date
Dim i As Long
Select Case Sheets("Contratti").Cells(2, 1)
Case Empty
i = 2
If Not (Sheets("Contratti").Cells(2, 1) = Empty) Then
Do Until Sheets("Contratti").Cells(i, 1) = Empty
ComboBox3.AddItem (Sheets("Contratti").Cells(i, 1).Value)
i = i + 1
Loop
End If
Case Else
With ComboBox3
.ColumnCount = 3
.BoundColumn = 3
.ColumnWidths = "40;40;20"
End With
With Sheets("Contratti")
frmlivelli.ComboBox3.List = .Range(.Cells(2, 1), .Cells(2, 3).End(xlDown)).Value
End With
End Select
'Codice per riempimento combobox4
'Riempimento numero fattura
With Sheets("Archivio").Range("A1").CurrentRegion
Righe = .Rows.Count
Colonne = .Columns.Count
Set Intervallo = .Offset(1, 0).Resize(Righe, Colonne)
End With
On Error Resume Next
For Riga = 1 To Righe
Elenco.Add Intervallo(Riga, 1).Value, CStr(Intervallo(Riga, 1).Value)
Next
On Error GoTo 0
With Intervallo
For Riga = 1 To Righe
If .Item(Riga, 1) = Codice Then
ComboBox4.AddItem (.Item(Riga, 5))
End If
Next
End With
End Sub
|