Ciao,
sinceramente continuo a non capire.
Mi dici che non vuoi scorrere tutto il foglio però mi dai come esempio una macro che non ha condizioni di uscita anticipata e che quindi scorre tutto il foglio... mah
Comunque, visto che quelle macro sul mio excel non funzionano ho messo un po' a posto la prima, vedi se ti risolve il problema se no, per favore, spiegami qual è il problema:
codice:
Sub cerca()
Sheets("Foglio1").Select
Set Rng = ActiveSheet.Range("D1:D1200")
riga = 1
contatore = 0
cdata1 = Application.InputBox("Inserisci la 1° data", "Ricerca per data", Format(Date, "dd/mm/yyyy"))
If Not cdata1 = False Then
If IsDate(cdata1) Then
cdata1 = Format(cdata1, "yyyy/mm/dd")
cdata2 = Application.InputBox("Inserisci la 2° data", "Ricerca per data", Format(Date, "dd/mm/yyyy"))
If Not cdata2 = False Then
If IsDate(cdata2) Then
cdata2 = Format(cdata2, "yyyy/mm/dd")
If cdata1 <= cdata2 Then
Sheets("Foglio2").Cells.Clear
For Each cell In Rng.Cells
If cell.Value = "" Then
Exit For
Else
If Format(cell.Value, "yyyy/mm/dd") >= cdata1 And Format(cell.Value, "yyyy/mm/dd") <= cdata2 Then
Rows(cell.Row).Select
Selection.Copy Destination:=Sheets("Foglio2").Cells(riga, 1)
riga = riga + 1
contatore = contatore + 1
End If
End If
Next
End If
Else
MsgBox "Data errata"
End If
End If
Else
MsgBox "Data errata"
End If
End If
[A1].Select
MsgBox contatore & " righe copiate"
End Sub