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
270 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
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Ken Fayal
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now