Thread: Copy Data
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Copy Data

Sub CurMonth()
Dim rng as Range, sh as Worksheet
set rng = Sheets("CasCrd").Rows("2:2")
Sheets("CasCrd").Range(rng, rng.End(xlDown)).Delete Shift:=xlUp

For Each Sh In WorkSheets
If Instr(1,Sh.Name, Right( _
Sheets("Interface").[C2],2),vbTextCompare) 0 then
sh.Range("A1").AutoFilter Field:=4, Criteria1:="N"
sh.Autofilter.Range.Resize(,42).Offset(1, 0).Copy _
Destination:=Sheets("CasCrd"). _
Range("A65536").End(xlUp).Offset(1, 0)
Sh.AutoFilterMode = False
End If
Next
End Sub

If it doesn't copy the data you expect, then you need to check if what

Right(Sheets("Interface").[C2],2)

produces and if that value is found in any of the sheet names.

--
Regards,
Tom Ogilvy
"Mas" wrote in message
...
Hi All,

I have several worksheets in my workbook.
i want to copy filtered data(if field 4 ="N") from each
sheet based on the sheet name (if the sheet name
contains "02") to last sheet (sheet45)

how can I do this using code?

Thanks
Mas