Macro copy with criteria
this code will work except I'm not sure how the dates are store in column g.
I used autofilter and the format of the filtered data in the autofilter may
need to be changed for the code to work. In the us I founc the date and
month are not two digits so you may have to modify the filter to look like
this
from
MyWorkbook = "" & Format(Date, "dd.mm.yyyy")
to
MyWorkbook = "" & Format(Date, "d.m.yyyy")
You will need a different formated date for opening the workbook and the
date used in the autofilter.
I also modifiy the code to specify the worksheets rather than to relie on
the active sheet.
Sub COPY()
MyWorkbook = "" & Format(Date, "dd.mm.yyyy")
Set bk = Workbooks.Open( _
Filename:="C:\Users\puiut\Desktop\try copy add\Copy Luke\" & _
MyWorkbook & ".xls")
Set bk = ThisWorkbook
With bk.Sheets(1)
LastRow = .Range("G" & Rows.Count).End(xlUp).Row
.Columns("G").AutoFilter
.Columns("G").AutoFilter Field:=1, _
Criteria1:=MyWorkbook
.Rows("2:" & LastRow).SpecialCells( _
Type:=xlCellTypeVisible).COPY
End With
With Workbooks("Database.xls").ActiveSheet
.Rows(2).PasteSpecial _
Paste:=xlPasteValues
.Range("B2").Select
End With
End Sub
"puiuluipui" wrote:
Hi, can this macro can be modified to copy from range A6:G100 rows that has
in G column today's date?(18.09.2009)
Sub COPY()
MyWorkbook = "" & Format(Date, "dd.mm.yyyy")
Workbooks.Open Filename:="C:\Users\puiut\Desktop\try copy add\Copy Luke\" &
MyWorkbook & ".xls"
Range("A5:T200").Select
Selection.COPY
Windows("Database.xls").Activate
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("B2").Select
End Sub
Can this be done?
Thanks!
|