On my Golf Handicap workbook and using the golfer’s names listed in column B, I use an InputBox as a way to enter each players scores in turn, onto the current worksheet in 2 different columns. (L & AM)
I need to limit the score I can enter in the InputBox to just 2 numbers (i.e. 99 or less). Can anyone suggest any additions to my part-code that will meet my needs?
Any help appreciated.
I need to limit the score I can enter in the InputBox to just 2 numbers (i.e. 99 or less). Can anyone suggest any additions to my part-code that will meet my needs?
Code:
Sub AddScore()
Dim ListRow As Integer, ListColumn As Integer, NewDataColumn As Integer, NewDataColumn2 As Integer
Dim MyNewData As String
Dim iRet As Integer
' Using Names in Columns B, Add new Scores to Columns L & AM
Application.ScreenUpdating = True
ListRow = 10: ListColumn = 2: NewDataColumn = 12: NewDataColumn2 = 39 '(Columns B, L & AM)
While ActiveSheet.Cells(ListRow, ListColumn) <> ""
MyNewData = InputBox("Enter the Scores for:- " & vbNewLine & vbNewLine _
& ActiveSheet.Cells(ListRow, ListColumn) & vbNewLine & vbNewLine & vbNewLine _
& "Click 'OK' or press 'Enter' to add next players score." & vbNewLine & vbNewLine _
& "(If a Player did not play - click 'OK' or press 'Enter')", _
"Add Scores", ActiveSheet.Cells(ListRow, NewDataColumn)) 'Get input
If MyNewData <> "" Then
ActiveSheet.Cells(ListRow, NewDataColumn) = MyNewData 'If input is not empty, use the input
ActiveSheet.Cells(ListRow, NewDataColumn2) = MyNewData
Else: ActiveSheet.Cells(ListRow, NewDataColumn) = ""
End If
ListRow = ListRow + 1
Wend
End Sub
Any help appreciated.