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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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