Because You hide Columns("C:NI")
and unhide only 30 columns from column C to column AF.
Range("B3").Value
equals to 1 and Range("B3").Value * 31 - 29
equals to 2.
Likewise, Range("B3").Value * 31 + 1
equals to 32. So, you unhide only 30 columns (32-2)!
Just change your VBA code Range("B3").Value * 31 - 29
to Range("B3").Value * 31 -28
and Range("B3").Value * 31 + 1
to Range("B3").Value * 31 + 2
:
Sub showcalendar()
LeaveTracker.Columns("C:NJ").Hidden = True
LeaveTracker.Range(Columns(Range("B3").Value * 31 - 28), Columns(Range("B3").Value * 31 + 2)).Hidden = False
End Sub
And one more thing, change all Column()-1
to Column()-2
in your excel formulaes. Here is your repaired workbook. Check and tell me any your ideas.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…