copying data from multiple sheets into single sheet using DATE criteria

AKeena

New Member
Joined
Sep 11, 2017
Messages
1
hi,
i want to know the error in the below code. i am applying this code to copy data from sheet2 to sheet1 based on DATE criteria.

Sub CommandButton1()
Dim lastrow, i, erow As Integer
Dim sh As Worksheet
Dim cell As Range
Dim sheets As Worksheet


Set sheets = ActiveWorkbook.Worksheets("sheet2")
lastrow = sheets("sheet2").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If cell(i, 1) = "29/10/1993" Then
Range(Cells(i, 1), Cells(i, 3)).Select
Selection.Copy
Set sh = ActiveWorkbook.Worksheets("sheet1")


sheets("Sheet1").Select
erow = sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
sheets("Sheet1").Cells(erow, 1).Select
ActiveSheet.Paste
End If
Next i
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top