powerpivotlegal
New Member
- Joined
- May 14, 2014
- Messages
- 30
Hello,
I was hoping there was a macro that could calculate the week ending date for a cell and then override the data in the same cell with the correct week-ending date.
So if a user input the date as 1/20/16, the macro would automatically execute and override that date and change it to 1/23/16 (i.e. the week-ending date).
All I have so far is the following:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.cells <> "" Then
A2+7-WEEKDAY(A2,1)
End If
End Sub
Many thanks
I was hoping there was a macro that could calculate the week ending date for a cell and then override the data in the same cell with the correct week-ending date.
So if a user input the date as 1/20/16, the macro would automatically execute and override that date and change it to 1/23/16 (i.e. the week-ending date).
All I have so far is the following:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.cells <> "" Then
A2+7-WEEKDAY(A2,1)
End If
End Sub
Many thanks