fluxcapacitr609
New Member
- Joined
- Feb 21, 2018
- Messages
- 24
Im trying to to extract data and push it to another sheet based on date. The code I have works but only does column A and B when C and D has information in it also. Any help would be greatly appreciated thank you.
Sub extractDataBasedOnDate()
Dim lastrow As Long
Dim erow As Long
Dim i As Long
lastrow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row
Sheet2.Select
Range("A1").Select
For i = 2 To lastrow
mydate = Cells(i, 1)
If mydate >= "2018-02-01" And mydate <= "2018-02-29" Then
erow = Sheet4.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Range(Cells(i, 1), Cells(i, 2)).Copy Destination:=Sheet4.Cells(erow, 1)
End If
Next i
End Sub
Sub extractDataBasedOnDate()
Dim lastrow As Long
Dim erow As Long
Dim i As Long
lastrow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row
Sheet2.Select
Range("A1").Select
For i = 2 To lastrow
mydate = Cells(i, 1)
If mydate >= "2018-02-01" And mydate <= "2018-02-29" Then
erow = Sheet4.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Range(Cells(i, 1), Cells(i, 2)).Copy Destination:=Sheet4.Cells(erow, 1)
End If
Next i
End Sub