![]() |
Macro-copy
Hi Luke. This is my code:
Sub COPY() Range("B2").Select Windows("17.09.2009.xls").Activate Range("A5:T200").Select Selection.COPY Windows("Database.xls").Activate ActiveSheet.Paste Range("B2").Select End Sub I want to copy from "date workbook"(17.09.2009) to Database Tomorow i will need to copy from "date workbook"(18.09.2009) to Database ...... Were can i insert your part of the code? I don't know how to do this. Thanks! "Luke M" a scris: Perhaps something like this? MyWorkBook = "was" & Format(Date, "dd.mm.yyyy") Workbooks.Open Filename:= _ "C:\Documents and Settings\My Documents\" & MyWorkBook & ".xls" -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "puiuluipui" wrote: Hi, i need to copy a range from another workbook, but the name of the workbook is different each day, so i need to copy from a workbook that is named as dates (Today) yesterday workbook's name was16.09.2009. today workbook's name is 17.09.2009. I don't want to change macro, so i need to copy from a workbook with name as Date (Today's date) Can this be done? Thanks! |
Macro-copy
Since you've already got the other workbook open, change code to:
Sub COPY() MyWorkbook = Format(Date, "dd.mm.yyyy") & ".xls" Range("B2").Select Windows(MyWorkbook).Activate Range("A5:T200").Select Selection.COPY Windows("Database.xls").Activate ActiveSheet.Paste Range("B2").Select End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "puiuluipui" wrote: Hi Luke. This is my code: Sub COPY() Range("B2").Select Windows("17.09.2009.xls").Activate Range("A5:T200").Select Selection.COPY Windows("Database.xls").Activate ActiveSheet.Paste Range("B2").Select End Sub I want to copy from "date workbook"(17.09.2009) to Database Tomorow i will need to copy from "date workbook"(18.09.2009) to Database ..... Were can i insert your part of the code? I don't know how to do this. Thanks! "Luke M" a scris: Perhaps something like this? MyWorkBook = "was" & Format(Date, "dd.mm.yyyy") Workbooks.Open Filename:= _ "C:\Documents and Settings\My Documents\" & MyWorkBook & ".xls" -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "puiuluipui" wrote: Hi, i need to copy a range from another workbook, but the name of the workbook is different each day, so i need to copy from a workbook that is named as dates (Today) yesterday workbook's name was16.09.2009. today workbook's name is 17.09.2009. I don't want to change macro, so i need to copy from a workbook with name as Date (Today's date) Can this be done? Thanks! |
Macro-copy
Hi Luke, and if i will have my workbook closed, how can the code look like?
Maybe i will try your first option. Thanks! "Luke M" a scris: Since you've already got the other workbook open, change code to: Sub COPY() MyWorkbook = Format(Date, "dd.mm.yyyy") & ".xls" Range("B2").Select Windows(MyWorkbook).Activate Range("A5:T200").Select Selection.COPY Windows("Database.xls").Activate ActiveSheet.Paste Range("B2").Select End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "puiuluipui" wrote: Hi Luke. This is my code: Sub COPY() Range("B2").Select Windows("17.09.2009.xls").Activate Range("A5:T200").Select Selection.COPY Windows("Database.xls").Activate ActiveSheet.Paste Range("B2").Select End Sub I want to copy from "date workbook"(17.09.2009) to Database Tomorow i will need to copy from "date workbook"(18.09.2009) to Database ..... Were can i insert your part of the code? I don't know how to do this. Thanks! "Luke M" a scris: Perhaps something like this? MyWorkBook = "was" & Format(Date, "dd.mm.yyyy") Workbooks.Open Filename:= _ "C:\Documents and Settings\My Documents\" & MyWorkBook & ".xls" -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "puiuluipui" wrote: Hi, i need to copy a range from another workbook, but the name of the workbook is different each day, so i need to copy from a workbook that is named as dates (Today) yesterday workbook's name was16.09.2009. today workbook's name is 17.09.2009. I don't want to change macro, so i need to copy from a workbook with name as Date (Today's date) Can this be done? Thanks! |
Macro-copy
It's working. I forgot to click yes. Sorry.
And i manage to make this work from a closed workbook from your first post. Thanks allot! "Luke M" wrote: Since you've already got the other workbook open, change code to: Sub COPY() MyWorkbook = Format(Date, "dd.mm.yyyy") & ".xls" Range("B2").Select Windows(MyWorkbook).Activate Range("A5:T200").Select Selection.COPY Windows("Database.xls").Activate ActiveSheet.Paste Range("B2").Select End Sub -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "puiuluipui" wrote: Hi Luke. This is my code: Sub COPY() Range("B2").Select Windows("17.09.2009.xls").Activate Range("A5:T200").Select Selection.COPY Windows("Database.xls").Activate ActiveSheet.Paste Range("B2").Select End Sub I want to copy from "date workbook"(17.09.2009) to Database Tomorow i will need to copy from "date workbook"(18.09.2009) to Database ..... Were can i insert your part of the code? I don't know how to do this. Thanks! "Luke M" a scris: Perhaps something like this? MyWorkBook = "was" & Format(Date, "dd.mm.yyyy") Workbooks.Open Filename:= _ "C:\Documents and Settings\My Documents\" & MyWorkBook & ".xls" -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "puiuluipui" wrote: Hi, i need to copy a range from another workbook, but the name of the workbook is different each day, so i need to copy from a workbook that is named as dates (Today) yesterday workbook's name was16.09.2009. today workbook's name is 17.09.2009. I don't want to change macro, so i need to copy from a workbook with name as Date (Today's date) Can this be done? Thanks! |
All times are GMT +1. The time now is 02:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com