There's a number of different ways you could do this. I'll offer 3 options here.
1. VBA
Right click the sheet tab name, select View Code, and place the following module in the code window that appears on the right of screen. You'll need to save the file as macro-enabled or binary. I've used a data validation rule in cell C7 to only accept whole numbers from 1 to 24.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("C7"), Target) Is Nothing Then
On Error GoTo Escape
Application.EnableEvents = False
Application.ScreenUpdating = False
Rows("9:32").Hidden = True
Range("B9").Resize(Target).EntireRow.Hidden = False
End If
Continue:
Application.EnableEvents = True
Application.ScreenUpdating = True
Exit Sub
Escape:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Continue
End Sub
Result when you enter 15:
2. Conditional Formatting
This doesn't hide the rows, but turns the font white so as to 'disappear'. When you enter 19 in C7 it looks like this:
3. Filter function. Your profile says you have 365, so you could use the Filter function like this - only returns the relevant rows but requires a secondary range: When you enter 22 in C7 you get this: (you could place the filtered range on another sheet if you wanted)