english version -> see IT Version

The first time I opened Excel, I don’t remember which version it was, it was running on Windows 3.1. I remember looking at the screen for a few seconds, fascinated by the colors and the many buttons with pictures on them. The grid intrigued me. I closed it and didn’t reopen it for a very long time. Obviously, I didn’t understand its potential, and I didn’t know what to do with it. I was of school age and thought it was like that.

Today I know well that without Excel, many tasks at work would have to be processed differently, taking ages and with much more effort. When I started to take work more seriously, I realized that too many things depended on knowledge, particularly the ability to work well and in an organized manner. In my early working years, I drew a lot of inspiration from my father’s way of working, who always told me that if he had a task he estimated to take 100 hours, he would spend 30 studying how to make the computer work and finish the rest in one hour.
Just like the habit of making my bed in the morning, I began to think the same way. My rule to myself became “before working, analyze, then plan, and finally do.”

In the equation of time, there was also “studying.” Back then, you didn’t ask Dr. Google how to do: “blah blah blah.” This meant having (expensive) books in hand and looking for the solution!
There was Yahoo, which was still a great search engine, but Google distinguished itself in the following years, between the late ’90s and early 2000s, for the quality of its results, displayed in an organized manner in a very short time. Regardless, over the course of now 27 years at work, I’ve found myself adapting to many situations. The one in the title is one.

To automatically insert the date in an Excel cell by double-clicking, you can use a VBA (Visual Basic for Applications) macro. Here’s how to write it assuming you have never used VBA before.

  1. Open your Excel File.
  2. Go in “File” -> Option
  3. “Customize your multifunction bar”
  4. “Scroll through the list on the right, look for ‘Development’ -> Activate it with a checkmark in the box, which will then turn green.”
  5. By following the right steps, now it would be time to “Save” your file making sure the extension is .xlsm (m stands for macro). BE CAREFUL of two things to remember, the first is that the default file extension of Excel is .xlsx, the macro will not be active and working; the second, more related to the example, is that if you do not save your file with the right extension first, Excel and VB start to get angry showing messages that can lead to confusion. The messages in the short tell you that to continue you must do as indicated in step 6.
  6. Once you have fixed step 6, then Press Alt + F11 to open the VBA Editor.
  7. In the left menu, double-click the name of the worksheet where you want to insert the date (for example, Sheet1).
  8. paste next VBA code in VB window:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    ' Controlla se la cella è vuota
    If Target.Value = "" Then
        ' Inserisce la data corrente nella cella
        Target.Value = Date
        ' Impedisce l'entrata in modalità modifica
        Cancel = True
    End If
End Sub

Close the VBA Editor and return to your worksheet. Now, when you double-click on any empty cell in the worksheet, the current date will be automatically inserted.

In all versions of Excel, the method is the same, although the terms might vary slightly. However, by paying close attention, you can overcome all challenges. In Excel, dates can be entered in many ways, one of which is this. Generally, the function above is very practical. You might need to customize the same function by including the time, or, for example, within a specific range of columns. You can customize the function as you prefer and need. Sorry my software version is italian (i am italian). you can see that the structure is the same.
Thank you for reading.
See you soon…

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Trending