Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro copy with criteria
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! |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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! |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro copy with criteria
Hi Joel. I've made a misstake. This is the code i need to be changed:
Sub copyanul() Workbooks.Open Filename:="C:\Users\puiut\Desktop\login password\apollo\Comenzi ANULATE 2009.xls" Range("B3").Select Range("A8:G250").Select Selection.COPY Windows("Database.xls").Activate Range("B3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Columns("B:H").EntireColumn.AutoFit Range("E:E,H:H").Select Range("H1").Activate Application.CutCopyMode = False Selection.NumberFormat = "m/d/yyyy" Range("B3").Select Application.CutCopyMode = False Windows("Comenzi ANULATE 2009.xls").Close End Sub I tried to adjust your code to this code, but i can't do it. Can you make this code copy only rows, from A8:G250 range, with today date in G column? The same thing like before, but with this code. Sorry again. Thanks! "Joel" wrote: 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! |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro copy with criteria
Try these changes
Sub COPY() DateStr = Format(Date, "m/d/yyyy") Set bk = Workbooks.Open( _ Filename:="C:\Users\puiut\Desktop\login password\" & _ apollo\Comenzi ANULATE 2009.xls" With bk.Sheets(1) .Range("G").NumberFormat = fiormat(Date,"m/d/yyyy" LastRow = .Range("G" & Rows.Count).End(xlUp).Row .Columns("G").AutoFilter .Columns("G").AutoFilter Field:=1, _ Criteria1:=DateStr .Rows("2:" & LastRow).SpecialCells( _ Type:=xlCellTypeVisible).Copy End With With Workbooks("Database.xls").ActiveSheet .Rows(2).PasteSpecial _ Paste:=xlPasteValues .Range("B2").Select .Columns("B:H").AutoFit .Range("E:E,H:H").NumberFormat = "m/d/yyyy" .Range("B3").Select End With bk.Close savechanges:=false End Sub "puiuluipui" wrote: Hi Joel. I've made a misstake. This is the code i need to be changed: Sub copyanul() Workbooks.Open Filename:="C:\Users\puiut\Desktop\login password\apollo\Comenzi ANULATE 2009.xls" Range("B3").Select Range("A8:G250").Select Selection.COPY Windows("Database.xls").Activate Range("B3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Columns("B:H").EntireColumn.AutoFit Range("E:E,H:H").Select Range("H1").Activate Application.CutCopyMode = False Selection.NumberFormat = "m/d/yyyy" Range("B3").Select Application.CutCopyMode = False Windows("Comenzi ANULATE 2009.xls").Close End Sub I tried to adjust your code to this code, but i can't do it. Can you make this code copy only rows, from A8:G250 range, with today date in G column? The same thing like before, but with this code. Sorry again. Thanks! "Joel" wrote: 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! |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro copy with criteria
Hi Joel, i have some errors.
First i had errors with: Set bk = Workbooks.Open( _ Filename:="C:\Users\puiut\Desktop\login password\" & _ apollo\Comenzi ANULATE 2009.xls" And i made it like this: Set bk = Workbooks.Open(Filename:="C:\Users\puiut\Desktop\l ogin password\apollo\Comenzi ANULATE 2009.xls") And now i have problem with this: .Range("G").NumberFormat = Format(Date, "dd.mm.yyyy" This line is highlited with yellow. What am i doing wrong? Thanks! "Joel" wrote: Try these changes Sub COPY() DateStr = Format(Date, "m/d/yyyy") Set bk = Workbooks.Open( _ Filename:="C:\Users\puiut\Desktop\login password\" & _ apollo\Comenzi ANULATE 2009.xls" With bk.Sheets(1) .Range("G").NumberFormat = fiormat(Date,"m/d/yyyy" LastRow = .Range("G" & Rows.Count).End(xlUp).Row .Columns("G").AutoFilter .Columns("G").AutoFilter Field:=1, _ Criteria1:=DateStr .Rows("2:" & LastRow).SpecialCells( _ Type:=xlCellTypeVisible).Copy End With With Workbooks("Database.xls").ActiveSheet .Rows(2).PasteSpecial _ Paste:=xlPasteValues .Range("B2").Select .Columns("B:H").AutoFit .Range("E:E,H:H").NumberFormat = "m/d/yyyy" .Range("B3").Select End With bk.Close savechanges:=false End Sub "puiuluipui" wrote: Hi Joel. I've made a misstake. This is the code i need to be changed: Sub copyanul() Workbooks.Open Filename:="C:\Users\puiut\Desktop\login password\apollo\Comenzi ANULATE 2009.xls" Range("B3").Select Range("A8:G250").Select Selection.COPY Windows("Database.xls").Activate Range("B3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Columns("B:H").EntireColumn.AutoFit Range("E:E,H:H").Select Range("H1").Activate Application.CutCopyMode = False Selection.NumberFormat = "m/d/yyyy" Range("B3").Select Application.CutCopyMode = False Windows("Comenzi ANULATE 2009.xls").Close End Sub I tried to adjust your code to this code, but i can't do it. Can you make this code copy only rows, from A8:G250 range, with today date in G column? The same thing like before, but with this code. Sorry again. Thanks! "Joel" wrote: 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! |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro copy with criteria
.Columns("G").NumberFormat = format(Date,"m/d/yyyy")
"puiuluipui" wrote: Hi Joel, i have some errors. First i had errors with: Set bk = Workbooks.Open( _ Filename:="C:\Users\puiut\Desktop\login password\" & _ apollo\Comenzi ANULATE 2009.xls" And i made it like this: Set bk = Workbooks.Open(Filename:="C:\Users\puiut\Desktop\l ogin password\apollo\Comenzi ANULATE 2009.xls") And now i have problem with this: .Range("G").NumberFormat = Format(Date, "dd.mm.yyyy" This line is highlited with yellow. What am i doing wrong? Thanks! "Joel" wrote: Try these changes Sub COPY() DateStr = Format(Date, "m/d/yyyy") Set bk = Workbooks.Open( _ Filename:="C:\Users\puiut\Desktop\login password\" & _ apollo\Comenzi ANULATE 2009.xls" With bk.Sheets(1) .Range("G").NumberFormat = fiormat(Date,"m/d/yyyy" LastRow = .Range("G" & Rows.Count).End(xlUp).Row .Columns("G").AutoFilter .Columns("G").AutoFilter Field:=1, _ Criteria1:=DateStr .Rows("2:" & LastRow).SpecialCells( _ Type:=xlCellTypeVisible).Copy End With With Workbooks("Database.xls").ActiveSheet .Rows(2).PasteSpecial _ Paste:=xlPasteValues .Range("B2").Select .Columns("B:H").AutoFit .Range("E:E,H:H").NumberFormat = "m/d/yyyy" .Range("B3").Select End With bk.Close savechanges:=false End Sub "puiuluipui" wrote: Hi Joel. I've made a misstake. This is the code i need to be changed: Sub copyanul() Workbooks.Open Filename:="C:\Users\puiut\Desktop\login password\apollo\Comenzi ANULATE 2009.xls" Range("B3").Select Range("A8:G250").Select Selection.COPY Windows("Database.xls").Activate Range("B3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Columns("B:H").EntireColumn.AutoFit Range("E:E,H:H").Select Range("H1").Activate Application.CutCopyMode = False Selection.NumberFormat = "m/d/yyyy" Range("B3").Select Application.CutCopyMode = False Windows("Comenzi ANULATE 2009.xls").Close End Sub I tried to adjust your code to this code, but i can't do it. Can you make this code copy only rows, from A8:G250 range, with today date in G column? The same thing like before, but with this code. Sorry again. Thanks! "Joel" wrote: 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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro criteria copy | Excel Discussion (Misc queries) | |||
Macro - How to not copy blank criteria? | Excel Worksheet Functions | |||
copy data with criteria | Excel Discussion (Misc queries) | |||
under certain criteria copy data. | Excel Worksheet Functions |