Forum Discussion
Macros for hiding rows based on date
With your permission, if I can recommend, It’s helpful to know your operating system and Excel version, as different approaches may be required depending on the version and OS.
Nevertheless,, give this a try (untested but should work)
Private Sub Worksheet_Activate()
Dim i As Long
Dim heute As Date
Sheets("Topics for the next meeting ").Activate
For i = ActiveSheet.UsedRange.Rows.Count to 1 Step -1
Range("A" & i).Select
If ActiveCell.Value > date - 1 Then
ActiveCell.EntireRow.Hidden = True
Else
End If
Next i
End Sub
'Please adjust according to your needsThank you for your understanding and patience
I would be happy to know if I could help.
Nikolino
I know I don't know anything (Socrates)
* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here
NikolinoDE Thank you! Yes it did work except I used it to search in the F Column but it starts searching around row 1100 - Is there a way to have it only search until the last row - which could change as information is added to the main sheet.
- NikolinoDENov 06, 2020Platinum Contributor
It should look for the date and hide or unhide from there.
What if a date in between ends before?
In the end anything is possible, it depends on the effort.
Should it only take the last entered date in F and then work up according to your requirements?
I don't recommend it, but if that's your wish ... I'll try to prepare it for you (starting tomorrow, after church and after Bistro :).
I think I'll have found the time by the day after tomorrow :)).
To be on the safe side, please describe to me step by step what the Macros should do.
Thank you for your understanding and patience
Nikolino
I know I don't know anything (Socrates)
- MVelveNov 06, 2020Copper Contributor
NikolinoDE Thank you! The first worksheet is entered by Admin staff. and needs to be left as is. The "Summary" sheet is the one we want to update and hide rows.
The dates in column F will be the date that the worksheet "Summary" goes by. The rows that are "< Date - 1" in column F will be hidden. Maybe another value to search would be that the Name has a value in it so that only the rows with a name and the dates will show in the Macro. What is your recommendation to make this better? A button will be created so when it is pressed, it will update the sheet based on this macro. What we want the Senior Staff to see are only the names of staff that are still not available for work. Another button would be created to unhide the rows if needed. Is this enough information from me?- NikolinoDENov 06, 2020Platinum Contributorabout searching around row 1100. Just change Range("A" & i).Select to Range("F2:F100" & i).Select, i think then search only 100 rows. Rest follows 🙂