VBA Help Trying to Last 8 Rows in Column A to todays date

PatrickW1907

New Member
Joined
Sep 3, 2022
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Hi

I've been using vba for a little while and still a novice. I have a spreadsheet where there are a list of dates in column A the date changes every 8 rows i.e. 1 to 8 = 31/08/2022 9 to 16 = 01/09/2022 . I'm looking at automation and want to code a macro that will find the bottom row with data in column A and change the bottom 8 cell values in column A to today's date. I cannot seem to find any useful info I imagine it will be last row -7 and something with the value property but appreciate any help or sdvice from anyone.

Kind regards

Patrick Wood
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Nothing nearly happens automatically in Excel.
But if you paste this code into your sheet and then double click on any cell in column A the script will do as you asked.
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  9/3/2022  3:16:28 PM  EDT
If Target.Column = 1 Then
Cancel = True
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(Lastrow, 1).Resize(8).Value = Date
End If
End Sub
 
Upvote 0
.. change the bottom 8 cell values in column A to today's date. ... I imagine it will be last row -7 and something with the value property
Welcome to the MrExcel board!

Sounds like it could be this?

VBA Code:
Sub TodaysDate()
  Range("A" & Rows.Count).End(xlUp).Offset(-7).Resize(8).Value = Date
End Sub
 
Upvote 0
Solution
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
 
Upvote 0
Welcome to the MrExcel board!

Sounds like it could be this?

VBA Code:
Sub TodaysDate()
  Range("A" & Rows.Count).End(xlUp).Offset(-7).Resize(8).Value = Date
End Sub

Hi Peter

This was the code I used that worked perfectly :)

Thank You!
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,844
Members
449,051
Latest member
excelquestion515

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