Ask Your Question
0

How can new worksheets be automatically generated and saved according to the date?

asked 2021-08-31 11:00:00 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-12-27 17:00:00 +0000

lakamha gravatar image

One way to generate and save worksheets automatically according to the date is to use a macro in Microsoft Excel. Here are the steps:

  1. Open Excel and create a new workbook.

  2. Press ALT + F11 to open the Visual Basic Editor.

  3. In the Visual Basic Editor, click on Insert > Module.

  4. In the new module, paste the following code:

Sub CreateWorksheet()

Dim SheetName As String Dim Sheet As Worksheet

SheetName = Format(Date, "MM-DD-YYYY") Set Sheet = ThisWorkbook.Sheets.Add

Sheet.Name = SheetName Sheet.SaveAs ThisWorkbook.Path & "\" & SheetName

End Sub

  1. Save the module and close the Visual Basic Editor.

  2. In the Excel workbook, select Developer > Macros.

  3. In the Macros dialog box, select the CreateWorksheet macro and click Run.

This macro will create a new worksheet with the name formatted as "MM-DD-YYYY" (e.g. "02-25-2022") and save it in the same folder as the workbook. Each time the macro is run, it will create a new worksheet with the current date as the name.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-31 11:00:00 +0000

Seen: 9 times

Last updated: Dec 27 '22