السلام عليكم ... هذه محاولة مني ..
Sub Button2_Click()
Dim LastRow
LastRow = Sheets(2).Cells(Sheets(2).Rows.Count, "B").End(xlUp).Row
Dim theSelection As Range
Set theSelection = Selection
If theSelection.Columns.Count <> 9 Then
MsgBox "please select 9 columns "
Exit Sub
End If
Dim usr_Date1 As Date
Dim usr_Date2 As Date
Dim TheString As String, FromDate, ToDate As Date
TheString = Application.InputBox("Enter the date1:")
If IsDate(TheString) Then
FromDate = DateValue(TheString)
Else
MsgBox "Invalid date"
Exit Sub
End If
TheString = Application.InputBox("Enter the date2:")
If IsDate(TheString) Then
ToDate = DateValue(TheString)
Else
MsgBox "Invalid date"
Exit Sub
End If
For i = 1 To theSelection.Rows.Count
'MsgBox theSelection.Cells(i, 4)
If theSelection.Cells(i, 4) <> "" And theSelection.Cells(i, 4).Value >= FromDate And theSelection.Cells(i, 4).Value <= ToDate Then
'MsgBox "ok"
LastRow = LastRow + 1
' Sheets(2).Cells(LastRow, 1) = theSelection.Cells(i, 1)
Sheets(2).Cells(LastRow, 2).Value = theSelection.Cells(i, 2).Value
Sheets(2).Cells(LastRow, 3) = theSelection.Cells(i, 3)
Sheets(2).Cells(LastRow, 4) = theSelection.Cells(i, 4)
Sheets(2).Cells(LastRow, 5) = theSelection.Cells(i, 5)
Sheets(2).Cells(LastRow, 6) = theSelection.Cells(i, 6)
Sheets(2).Cells(LastRow, 7) = theSelection.Cells(i, 7)
Sheets(2).Cells(LastRow, 8) = theSelection.Cells(i, 8)
Sheets(2).Cells(LastRow, 9) = theSelection.Cells(i, 9)
End If
Next
End Sub
الاشهر ترحيل.rar