VBA for date logging

afrobea_r

Board Regular
Joined
Aug 16, 2015
Messages
76
Dear Excel Wizards,

Currently I have a workbook that I use for record keeping everyday.

There are many columns of data in this workbook, one of which is a date column.

As I find it incredibly cumbersome to individually populate every single cell in each column as I move down the rows, I have some in-cell formulas in several cells that returns certain values based on information that I have to manually insert in cells of certain columns.

For the date column, I am using the =Today() function. However, how do I create a macro that dynamically copies all the latest dates (which is today) and then paste as values to the last cell using an adjacent cell as a marker for the last row, so that when it comes to the next day, the dates are archived in order, and the latest date is reflected in the new row?

Below is an example of some column headers that I have. Thank you!

Auto-RegionSourceWeekDate

<tbody>
</tbody>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Heres an example:

Code:
Set sh = Sheets("Sheet1")

With sh
    lrLong = .Range("A" & Rows.Count).End(xlUp).Row
    lrShort = .Range("B" & Rows.Count).End(xlUp).Row
    
    If lrLong > lrShort Then
        .Range(.Cells(lrShort + 1, "B"), .Cells(lrLong, "B")).Value = Date
    End If
End With

It assumes you want to fill in column B based on the last row of column A of sheet called 'Sheet1'.
 
Upvote 0
Many thanks sir!!

Heres an example:

Code:
Set sh = Sheets("Sheet1")

With sh
    lrLong = .Range("A" & Rows.Count).End(xlUp).Row
    lrShort = .Range("B" & Rows.Count).End(xlUp).Row
    
    If lrLong > lrShort Then
        .Range(.Cells(lrShort + 1, "B"), .Cells(lrLong, "B")).Value = Date
    End If
End With

It assumes you want to fill in column B based on the last row of column A of sheet called 'Sheet1'.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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