Meme,
Those 2 lines should be a single line, The NG wrapped around. Try this
slightly amended version
Sub CopyData()
Dim iLastRow As Long
With Worksheets("A")
iLastRow = .Cells(Rows.Count, "C").End(xlUp).Row
.Columns("E:E").EntireColumn.Insert
.Range("E2").FormulaR1C1 = "=AND(OR(RC[-3]=""user01""," & _
"RC[-3]=""user03""," & _
"RC[-3]=""user04""," & _
"RC[-3]=""user05"")," & _
"AND(RC[-2]>=DATE(2004,4,1)," & _
"RC[-2]<=DATE(2004,4,3)))"
.Range("E2").AutoFill Destination:=.Range("E2:E" & iLastRow), _
Type:=xlFillDefault
.Columns("E:E").AutoFilter Field:=1, Criteria1:="<>FALSE"
.Cells.SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("B").Range("A1")
.Columns("E:E").EntireColumn.Delete
End With
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
Meme said:
Hi Bob,
Thank you so much for the macro you gave to me. but some
how this following code has a syntax error when I ran the
macro. Please help me check this code:
.Range("E2").AutoFill Destination:=.Range("E2:E"
& iLastRow),Type:=xlFillDefault
Thank you in advance !
Meme
-----Original Message-----
Hi Meme,
Here is a macro
Sub CopyData()
Dim iLastRow As Long
With Worksheets("A")
iLastRow = .Cells(Rows.Count, "C").End(xlUp).Row
.Columns("E:E").EntireColumn.Insert
.Range("E2").FormulaR1C1 = "=AND(OR(RC[-3] =""user01""," & _
"RC[-3] =""user03""," & _
"RC[-3] =""user04""," & _
"RC[-3] =""user05"")," & _
"AND(RC[-2]>=DATE (2004,4,1)," & _
"RC[-2]<=DATE (2004,4,3)))"
.Range("E2").AutoFill Destination:=.Range("E2:E" & iLastRow),
Type:=xlFillDefault
.Columns("E:E").AutoFilter Field:=1,
Criteria1:= said:
.Cells.SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("B").Range("A1")
.Columns("E:E").EntireColumn.Delete
End With
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
.