Ciao Mauro, forse facevo bene a postare tutto il codice in modo che tu potessi valutarlo nel suo insieme.
In pratica con questo codice provvedo ad estrarre da un elenco alcuni record in base ad una data iniziale ed una finale.
La mia necessità è quella di riprendere le due date , iniziale e fianle e riportarle dall' input box nelle celle A1 (DATA iNIZIALE) e A2 (DATA FINALE) del foglio2.
Ti posto l'intero codice:
Do Until IsDate(S1)
S1 = InputBox("Data Iniziale")
If S1 = "" Then Exit Sub
Loop
DataIni = CDate(S1)
Do Until IsDate(S2)
S2 = InputBox("Data Finale")
If S2 = "" Then Exit Sub
Loop
DataFin = CDate(S2)
If Not IsEmpty(SourceRange(2, 1)) Then
Set SourceRange = SourceRange.Resize _
(SourceRange.End(xlDown).Row - SourceRange.Row + 1)
End If
If Not IsEmpty(TargetRange(2, 1)) Then
Set TargetRange = TargetRange.Resize _
(TargetRange.End(xlDown).Row - TargetRange.Row + 1)
End If
Range(TargetRange(2, 1), TargetRange.Offset(, NumCol)).ClearContents
' Filtro
For Each i In SourceRange
If DataIni <= i.Offset(, 1) And i.Offset(, 1) <= DataFin Then
j = j + 1
For k = 1 To NumCol
TargetRange(j, k) = i(1, k)
Next
End If
Next
' Ordinamento
Range(TargetRange(1, 1), TargetRange(j, NumCol)).Sort _
Key1:=TargetRange(1, SortCol), _
Order1:=xlAscending, _
Orientation:=xlSortColumns, _
Header:=xlNo
Quindi dovrei intercettare le date che inserisco nell'Input box e fargliele copiare in A1 e A2.
Ho provato ad estrapolare qualcosa del tuo codice ma non sono riuscito a farlo funzioare, Vedi se ti riesce di modificare questo codice.
Grazie.