Solved

Is it possible to change a cell to the creation date value of each xls file in a folder?

Posted on 2011-02-16
4
278 Views
Last Modified: 2012-05-11
I have a folder with many Excel workbook files, 2003 version, in each.
Each workbook file has the same format and the same two worksheet names.
One worksheet has a cell with a date in it.
Is it possible to write a macro in a new Excel file that will identify the creation date of each file within the folder and change the cell value within each of the files to the date that the file was created?
0
Comment
Question by:spar-kle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Ken Fayal
ID: 34912759
You should be able to assign the value of the cell you want to

ActiveWorkbook.BuiltinDocumentProperties("Creation Date")

You can do this with VBA
0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 34913791
Hi again,

Something like this code would
- open every xls, xlsx, xlsm file under C;\temp
- write the create date in A1 of the first sheet as a date format
- close and save the file

Pls change this line
    strFolderName = "c:\temp"
to set your directory

This line
With Wb.Sheets(1).[a1]
if you wanted to change a different cell
ie for B10 on second sheet
With Wb.Sheets(2).[b10]

Cheers

Dave


Sub Change()
'uses http://www.experts-exchange.com/A_2839.html
    Dim Wb As Workbook
    Dim strFName As String
    Dim strFolderName As String
    strFolderName = "c:\temp"

    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
    End With

    strFName = Dir(strFolderName & "\*.xls*")
    Do While Len(strFName) > 0
        Set Wb = Workbooks.Open(strFolderName & "\" & strFName)
        With Wb.Sheets(1).[a1]
            .NumberFormat = "dd-mmm-yyyy"
            .Value = Wb.BuiltinDocumentProperties("Creation Date")
        End With
        Wb.Save
        Wb.Close
        strFName = Dir
    Loop

    With Application
        .ScreenUpdating = True
        .DisplayAlerts = True
        .StatusBar = vbNullString
    End With

End Sub

Open in new window

0
 

Author Comment

by:spar-kle
ID: 34919868
Sorry for delay, it's been a busy day...

Thanks CaptainKenbo, though not quite what I was after, I'll keep the code for future reference..

brettdj, ..that's excellent, and thankyou for the added explanations
Only problem is that the date is incorrect, I'm sure there must be a simple fix
ie todays date comes out as 07-Aug-2001
Can you please help..
Thanks
Des
0
 

Author Closing Comment

by:spar-kle
ID: 34920251
Thanks brettdj
Really good!!!!
My problem was with the formatting in the original files.
If I can't work it out I'll post another question
Thanks for your help, excellent
Des
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question