Wednesday, September 26, 2012

How To Create a Folder and a Excel File By Current Date And Time

Macro To Create a Folder and a Excel File By Current Date And Time
'We can use this Macro To Save Dalily Tasks from 'Regular Task Workbook' to a WorkBook with Current Date & Time

Sub CrtTaskShtByToday()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim e As String
On Error Resume Next
Application.DisplayAlerts = False

A = Day(Date) 'Day Value From Date
B = Month(Date) 'Month Value From Date
C = Year(Date) 'Year Value From Date
E = A & "-" & B & "-" &C

MkDir "D:\MyXlProjects\" & e 'Make a Desired Folder By Current Date & Time
Workbooks(e).Close

Workbooks.Add.SaveAs ("D:\MyXlProjects\" & E & "\" & E & ".xlsx")
'A Folder & File with Current Date& Time will be created

Workbooks("MainTask").Activate
ActiveWorkbook.ActiveSheet.Cells.Copy Workbooks(e).Sheets("Sheet1").Range("a1")
'Copy Data From Active Sheet to a Sheet1 of Newly Created Workbook

Workbooks(e).Save
Workbooks(e).Close
End Sub

Thanks,Tamatam

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog