Ask Your Question
4

How can a macro be added to an Excel template created in VBA Access to automatically populate the date whenever a cell contains values?

asked 2022-08-28 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-02-18 23:00:00 +0000

pufferfish gravatar image

To add a macro to an Excel template created in VBA Access to automatically populate the date whenever a cell contains values, follow these steps:

  1. Open the Excel template file in Microsoft Excel.

  2. Press the ALT + F11 keys to open the VBA editor.

  3. In the VBA editor, right-click on the sheet name where you want to add the macro and select "View Code".

  4. In the code window, enter the following code:

Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("A1:A100")) Is Nothing _ And Target.Value <> "" _ And Target.Offset(0, 1).Value = "" Then Target.Offset(0, 1).Value = Date End If End Sub

Note: Replace "A1:A100" with the range of cells where you want the macro to apply.

  1. Save the macro-enabled Excel template file.

Now, whenever you enter a value in one of the specified cells, the adjacent cell will automatically be populated with the current date.

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: 2022-08-28 11:00:00 +0000

Seen: 8 times

Last updated: Feb 18 '22