Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("H6")) Is Nothing Then Exit Sub
On Error Resume Next
Dim €Km As String
Dim i As Long, Nriga As Long
Dim Sh As String
Sh = "INSERIMENTO TRASFERTE"
Nriga = 20
€Km = InputBox("inserire solo valori numerici decimali col punto 0,41", "Onorario KM")
''Range("G20") = --(€Km)
Range("A20:I36").ClearContents
For i = 7 To Sheets(Sh).Cells(Rows.Count, 1).End(xlUp).Row
If Sheets(Sh).Cells(i, "B").Text = Range("H6") And Year(Sheets(Sh).Cells(i, "C")) = Range("I6") Then
Cells(Nriga, "A") = Sheets(Sh).Cells(i, "C")
Cells(Nriga, "B") = Sheets(Sh).Cells(i, "E")
Cells(Nriga, "C") = Sheets(Sh).Cells(i, "F")
Cells(Nriga, "F") = Sheets(Sh).Cells(i, "G")
Cells(Nriga, "G") = --(€Km)
Cells(Nriga, "H") = --(€Km) * Cells(Nriga, "F")
Cells(Nriga, "I") = Sheets(Sh).Cells(i, "N")
Nriga = Nriga + 1
End If
Next i
End Sub
|