Macro Insert column with date of today

Dimi70

New Member
Joined
Oct 28, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,
I am very bad at Macro and unless some research and practice by myself I could not figure out.

For my work I extract data daily from system in excel and I would like to create a macro that input in column "V" the date of the extraction.
The number of row can be change so I would like to input the date only on the row that are not empty (based on column A).
A file is generated in a new excel document so I need to have a macro that I can use directly from those excel file.

Can you help me?

Thank you in advance for your help
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi @Dimi70.
If I understood you correctly. You want to enter the extraction date in column "V" and enter the date only in those rows that are not empty (based on column A). Here is an option for you.
VBA Code:
Option Explicit

Sub InsertDate()
    Dim i           As Long

    With ThisWorkbook.Worksheets("Sheet1")   ' "Sheet1" you can change the name of your sheet where you will insert the date

        Dim lastRow As Long
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

        For i = 1 To lastRow

            If Not IsEmpty(.Cells(i, "A").Value) Then
                .Cells(i, "V").Value = Date
            End If

        Next i

    End With

End Sub
It was my pleasure to help you. Good luck.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top