KyleJackMorrison
Board Regular
- Joined
- Dec 3, 2013
- Messages
- 107
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
Hello, so I have a large code which runs a report on dates. I have this code 5 times with just an "offset" +0 +1, +2 +3 +4 (Simulating Monday, Tuesday, Wednesday, Thursday, Friday.)
This code at the moment an ONLY be run on a Monday.
I would like the code to run the weeks report no matter what day it is. Just run this week from moday-friday.
Perhaps replace this with something like:
to something like
(Mondays Code)
(Tuesdays code)
(Wednesday code)
ect.
TIA
This code at the moment an ONLY be run on a Monday.
I would like the code to run the weeks report no matter what day it is. Just run this week from moday-friday.
Perhaps replace this with something like:
Code:
If Cell.Value = [Today()] Then
Code:
If cell.value = [Monday of this week] then
(Mondays Code)
Code:
For Each Cell In ActiveSheet.Range("J10:NJ23")
If Cell.Value = [Today()] Then
Cell.Select
ActiveCell.Offset(1, 0).Select
Select Case Cell.Column
Case 10
Range("K:NO").EntireColumn.Hidden = True
Case 379
Range("J:NN").EntireColumn.Hidden = True
Case Else
Range("J11", Cells(11, Cell.Column - 1)).EntireColumn.Hidden = True
Range(Cells(11, Cell.Column + 1), Range("NO11")).EntireColumn.Hidden = True
End Select
(Tuesdays code)
Code:
For Each Cell In ActiveSheet.Range("J10:NJ23")
If Cell.Value = [Today()+1] Then
Cell.Select
ActiveCell.Offset(1, 0).Select
Select Case Cell.Column
Case 10
Range("K:NO").EntireColumn.Hidden = True
Case 379
Range("J:NN").EntireColumn.Hidden = True
Case Else
Range("J11", Cells(11, Cell.Column - 1)).EntireColumn.Hidden = True
Range(Cells(11, Cell.Column + 1), Range("NO11")).EntireColumn.Hidden = True
End Select
(Wednesday code)
Code:
For Each Cell In ActiveSheet.Range("J10:NJ23")
If Cell.Value = [Today()+2] Then
Cell.Select
ActiveCell.Offset(1, 0).Select
Select Case Cell.Column
Case 10
Range("K:NO").EntireColumn.Hidden = True
Case 379
Range("J:NN").EntireColumn.Hidden = True
Case Else
Range("J11", Cells(11, Cell.Column - 1)).EntireColumn.Hidden = True
Range(Cells(11, Cell.Column + 1), Range("NO11")).EntireColumn.Hidden = True
End Select
ect.
TIA