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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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