VBA - Run macro if last day of the week

OldAndWeak182

New Member
Joined
Apr 29, 2021
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hello,
My example: in A I have the 5 days of the working week and a list of stuff next to.
Every 5 days I create a summary of the week in 2 rows (with formula).
After this I created a button that runs a macro that copies the table format and formula extending next 5 days and creates the weekly report rows.
I would like it to run the macro by itself when it reaches the 5th day of the week. I hope I was clear, I have a bit of difficulty in translating...

Max
 

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.
Can't open the file but you could usze something like
VBA Code:
If Format(Now(), "DDD") = "FRI" Then "if today is Friday
'run code
 
Upvote 0
So, you want to run this macro Sub Aggingi_Week() every Friday ??
In your This Workbook module put...
S
VBA Code:
ub Workbook_open()
If Format(Now(), "DDD") = "FRI" Then
  Call Aggingi_Week
End If
End Sub
 
Upvote 0
So, you want to run this macro Sub Aggingi_Week() every Friday ??
In your This Workbook module put...
S
VBA Code:
ub Workbook_open()
If Format(Now(), "DDD") = "FRI" Then
  Call Aggingi_Week
End If
End Sub

almost, I would only run the macro when any Friday cell on the current week is filled in!
 
Upvote 0
Assuming the current week is at the bottom of the table
VBA Code:
Sub Workbook_open()
Dim lr As Long
lr = Sheets("andamento").Cells(Rows.Count, "B").End(xlUp).Row
If WorksheetFunction.CountA(Range(Cells(lr - 2, 2), Cells(lr - 2, 16))) = 0 Then
If Format(Now(), "DDD") = "FRI" Then
  Call Aggingi_Week
End If
End If
End Sub
 
Upvote 0
Assuming the current week is at the bottom of the table
VBA Code:
Sub Workbook_open()
Dim lr As Long
lr = Sheets("andamento").Cells(Rows.Count, "B").End(xlUp).Row
If WorksheetFunction.CountA(Range(Cells(lr - 2, 2), Cells(lr - 2, 16))) = 0 Then
If Format(Now(), "DDD") = "FRI" Then
  Call Aggingi_Week
End If
End If
End Sub

great, but I realized that the date is not actually a date and I can't change the format of that column.
In your opinion is there another way to achieve the same result knowing that we cannot use the date as a variable?
 
Upvote 0
My code doesn't need the column to be a date ! and doesn't use it as a variable !
The code I provided counts the cells from col "B" to Col "Q" If the are ALL blank it then moves onto
If today is Friday... run the code
nothing to do with what is in Col "A"
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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