Not sure if I should type the whole problem or just what I need help working with. I'll just go with the whole problem to see if someone can help me out.
Basically I made a worksheet that can calculate my fortnightly paycheck. Right now I can only calculate one pay period at a time (14 days) but I want to be able to see past pay periods as well based on the starting date cell. For example when I enter the pay period is between 2nd of July and 16th of July, I want excel to calculate the pay for that period and not only that, I also want to hide rows that are not between 2nd July and 16th.
So far I have this to hide the unnecessary rows:
Sub HdeRow()
ThisWorkbook.Worksheets("Kitchen").Rows("2:127").Hidden = True
ThisWorkbook.Worksheets("Cleaning").Rows("2:127").Hidden = True
ThisWorkbook.Worksheets("Touchpoint").Rows("2:127").Hidden = True
If ThisWorkbook.Worksheets("Payslip").Range("B19").Value = "07/06/2021" Then
ThisWorkbook.Worksheets("Kitchen").Rows("2:15").Hidden = False
ThisWorkbook.Worksheets("Cleaning").Rows("2:15").Hidden = False
ThisWorkbook.Worksheets("Touchpoint").Rows("2:15").Hidden = False
ElseIf ThisWorkbook.Worksheets("Payslip").Range("B19").Value = "21/06/2021" Then
ThisWorkbook.Worksheets("Kitchen").Rows("16:17").Hidden = False
ThisWorkbook.Worksheets("Cleaning").Rows("16:17").Hidden = False
ThisWorkbook.Worksheets("Touchpoint").Rows("16:17").Hidden = False
'ElseIf..... continuing for the whole year but thats takes a lot of time'
End If
End Sub
Any help would be hugely appreciated!
Also I was wondering how to do a range for dates, like from 16/4/21 To 30/4/21. How do you say "If this cell is between 'this date' and 'that date' Then dont hide this row.
Bookmarks