Private Sub ComboBox1_Change()
Dim myRange As Range
Set myRange = ThisWorkbook.Sheets("intrari").Range("B20").CurrentRegion
Me.ComboBox2.Clear
Me.ComboBox3.Clear
With Me.ComboBox2
.AddItem Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, myRange, 4, False)
.ListIndex = 0
End With
With Me.ComboBox3
.AddItem Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, myRange, 6, False)
.ListIndex = 0
End With
End Sub
Private Sub CommandButton1_Click()
Unload Userform1
End Sub
Private Sub CommandButton2_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("intrari")
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
For b = 1 To 14
ws.Cells(iRow, b).Borders.LineStyle = xlContinuous
Next b
ws.Cells(iRow, 1).Value = TextBox1.Text
ws.Cells(iRow, 2).Value = ComboBox1.Text
ws.Cells(iRow, 3).Value = ComboBox2.Text
ws.Cells(iRow, 4).Value = ComboBox3.Text
ws.Cells(iRow, 5).FormulaR1C1 = "=RC3*RC4"
ws.Cells(iRow, 6).Value = ComboBox4.Text
ws.Cells(iRow, 7).FormulaR1C1 = "=RC3*RC6"
ws.Cells(iRow, 8).Value = ComboBox5.Text
ws.Cells(iRow, 9).FormulaR1C1 = "=(RC7-RC5)/RC5"
ws.Cells(iRow, 13).Value = ComboBox6.Text
ws.Cells(iRow, 15).Value = ComboBox6.Text
'----------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------
If ws.Cells(iRow, 1).Value = ws.Cells(iRow - 1, 1).Value Then
ws.Cells(iRow, 14).Value = ws.Cells(iRow, 5).Value + ws.Cells(iRow - 1, 14).Value
ws.Cells(iRow - 1, 14).Value = ""
ws.Cells(iRow - 1, 14).Borders(xlEdgeTop).LineStyle = xlNone
ws.Cells(iRow - 1, 13).Borders(xlEdgeTop).LineStyle = xlNone
ElseIf ws.Cells(iRow, 1).Value = ws.Cells(iRow - 2, 1).Value Then
ws.Cells(iRow, 14).Value = ws.Cells(iRow, 5).Value + ws.Cells(iRow - 2, 14).Value
ws.Cells(iRow - 2, 14).Value = ""
ws.Cells(iRow - 2, 14).Borders(xlEdgeTop).LineStyle = xlNone
ws.Cells(iRow - 1, 13).Borders(xlEdgeTop).LineStyle = xlNone
Else
ws.Cells(iRow, 14).Value = ws.Cells(iRow, 5).Value
ws.Cells(iRow - 1, 13).Borders(xlEdgeTop).LineStyle = xlNone
End If
'-----------------------------------------------------------------------------------------------------
If ws.Cells(iRow, 13).Value = ws.Cells(iRow - 1, 15).Value Then
ws.Cells(iRow, 10).Formula = "=" & ws.Cells(iRow, 5).Address & "+" & ws.Cells(iRow - 1, 16).Address
ws.Cells(iRow, 16).Formula = "=" & ws.Cells(iRow, 5).Address & "+" & ws.Cells(iRow - 1, 16).Address
ws.Cells(iRow, 17).Formula = "=" & ws.Cells(iRow, 7).Address & "-" & ws.Cells(iRow, 5).Address & "+" & ws.Cells(iRow - 1, 17).Address
ws.Cells(iRow, 12).Formula = "=" & ws.Cells(iRow, 7).Address & "-" & ws.Cells(iRow, 5).Address & "+" & ws.Cells(iRow - 1, 17).Address
ws.Cells(iRow, 18).Formula = "=" & ws.Cells(iRow, 7).Address & "+" & ws.Cells(iRow - 1, 18).Address
ws.Cells(iRow, 11).Formula = "=" & ws.Cells(iRow, 3).Address & "*" & ws.Cells(iRow, 6).Address & "+" & ws.Cells(iRow - 1, 18).Address
ws.Cells(iRow, 19).Formula = "=" & ws.Cells(iRow - 1, 19) & "+1"
ws.Cells(iRow, 20).Formula = "=month(" & ws.Cells(iRow, 1).Address & ")"
ws.Cells(iRow - 1, 10).Borders(xlEdgeTop).LineStyle = xlNone
ws.Cells(iRow - 1, 11).Borders(xlEdgeTop).LineStyle = xlNone
ws.Cells(iRow - 1, 12).Borders(xlEdgeTop).LineStyle = xlNone
ws.Cells(iRow - 1, 10).ClearContents
ws.Cells(iRow - 1, 12).ClearContents
ws.Cells(iRow - 1, 11).ClearContents
ws.Cells(iRow - 1, 13).ClearContents
Else
ws.Cells(iRow, 10).FormulaR1C1 = "=RC3*RC4"
ws.Cells(iRow, 16).FormulaR1C1 = "=RC3*RC4"
ws.Cells(iRow, 17).Formula = "=" & ws.Cells(iRow, 7).Address & "-" & ws.Cells(iRow, 5).Address
ws.Cells(iRow, 11).Formula = "=" & ws.Cells(iRow, 3).Address & "*" & ws.Cells(iRow, 6).Address
ws.Cells(iRow, 12).Formula = "=" & ws.Cells(iRow, 7).Address & "-" & ws.Cells(iRow, 5).Address
ws.Cells(iRow, 18).Formula = "=" & ws.Cells(iRow, 3).Address & "*" & ws.Cells(iRow, 6).Address
ws.Cells(iRow, 19).Value = 1
ws.Cells(iRow, 20).Formula = "=month(" & ws.Cells(iRow, 1).Address & ")"
End If
'------------------------------------------------------------------------------------------------------
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
ComboBox4.Text = ""
ComboBox1.SetFocus
End Sub
Private Sub CommandButton3_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("intrari")
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If ws.Cells(iRow - 1, 3) > 0 Then
ws.Cells(iRow, 1).Value = ""
For a = 1 To 19
ws.Cells(iRow, a).Value = 0
ws.Cells(iRow, a).Interior.ColorIndex = 1
Next a
Rows(iRow).RowHeight = 5
Calcul_factura.Label5.Caption = ws.Cells(iRow - 1, 10).Value
Calcul_factura.Label8.Caption = ws.Cells(iRow - 1, 11).Value
Calcul_factura.Label11.Caption = ws.Cells(iRow - 1, 12).Value
Calcul_factura.Label14.Caption = ws.Cells(iRow - 1, 14).Value
Calcul_factura.Label17.Caption = ws.Cells(iRow - 1, 13).Value
Calcul_factura.Label12.Caption = ws.Cells(iRow - 1, 19).Value
Calcul_factura.Label19.Caption = ws.Cells(iRow - 1, 1).Value
Calcul_factura.Show
Else
Calcul_factura.Label5.Caption = ws.Cells(iRow - 2, 10).Value
Calcul_factura.Label8.Caption = ws.Cells(iRow - 2, 11).Value
Calcul_factura.Label11.Caption = ws.Cells(iRow - 2, 12).Value
Calcul_factura.Label14.Caption = ws.Cells(iRow - 2, 14).Value
Calcul_factura.Label17.Caption = ws.Cells(iRow - 2, 13).Value
Calcul_factura.Label12.Caption = ws.Cells(iRow - 2, 19).Value
Calcul_factura.Label19.Caption = ws.Cells(iRow - 2, 1).Value
Calcul_factura.Show
End If
End Sub
Private Sub UserForm_Click()
End Sub