Then perhaps:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyVal As Single, MyCol As Long

Select Case Target.Cells(1).Column
    Case 2, 6, 10, 14, 18                       'columns B, F, J, N and R
        MyCol = Target.Cells(1).Column + 37     'column AM, AQ, AU, AY and BC
        If Target.Cells(1).Value <> "" Then
            MyVal = Application.InputBox("How many hours for this task: " & Target.Cells(1).Value, "Hours", Type:=1)
            If MyVal > 0 Then Cells(Target.Cells(1).Row, MyCol).Value = MyVal Else Application.Undo
        Else
            Cells(Target.Cells(1).Row, MyCol).ClearContents
        End If
    
    Case Else
        'do nothing
End Select

End Sub