Macro-copy

P

puiuluipui

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!
 
L

Luke M

Perhaps something like this?

MyWorkBook = "was" & Format(Date, "dd.mm.yyyy")

Workbooks.Open Filename:= _
"C:\Documents and Settings\My Documents\" & MyWorkBook & ".xls"
 
P

puiuluipui

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:
 
L

Luke M

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
 
P

puiuluipui

Hi Luke... this workbook(with date name) will be open.
I don't want to open from folder because in this folder i will store all
workbooks (01.09.2009;02.09.2009;03.09.2009.....), so it will be dificult i
guess, that the macro to pick the last date. So, i want to copy from open
workbook with date as name.
Can this be done?
Thanks!


"Luke M" a scris:
 
P

puiuluipui

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:
 
P

puiuluipui

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top