Because I’ve no experience with InputBox’s, I’ve been given a code that allows me to show a list of names starting in Column 1 (A) – Row 10, (“A10”) allowing me to enter Data associated with that name, into Column 9. (“I”)
Unfortunately the list of names can be quite long and if possible, I would like to activate the “Cancel” button if the process has an error or not been completed correctly. Then if the “Cancel” button is clicked – I would like to follow it by a MsgBox, asking if the user wants to re-start the InputData routine from the top, or Exit completely.
Also if possible, I would also like to incorporate a confidence MsgBox at the end of the routine, to confirm if the process has been completed correctly, before moving on the next Sub.
e.g.
If the answer is ‘Yes’ – move on to next Sub.
If the answer is ‘No’ – return to the start of the InputData routine.
Ultimately I suppose create Loop until the user clicks ‘Yes’.
I’ve already tried to capture the confidence MsgBox at the end of the first attempt, It appears to work OK on the first occasion allowing me to re-enter all the Data again, but the confirmation MsgBox does not appear after the second InputBox run, allowing it to move on to next sub.
I know I’m asking a lot but any help appreciated.
Unfortunately the list of names can be quite long and if possible, I would like to activate the “Cancel” button if the process has an error or not been completed correctly. Then if the “Cancel” button is clicked – I would like to follow it by a MsgBox, asking if the user wants to re-start the InputData routine from the top, or Exit completely.
Also if possible, I would also like to incorporate a confidence MsgBox at the end of the routine, to confirm if the process has been completed correctly, before moving on the next Sub.
e.g.
If the answer is ‘Yes’ – move on to next Sub.
If the answer is ‘No’ – return to the start of the InputData routine.
Ultimately I suppose create Loop until the user clicks ‘Yes’.
I’ve already tried to capture the confidence MsgBox at the end of the first attempt, It appears to work OK on the first occasion allowing me to re-enter all the Data again, but the confirmation MsgBox does not appear after the second InputBox run, allowing it to move on to next sub.
Code:
Sub InputData()
Dim ListRow, ListColumn, NewDataColumn As Integer
Dim MyNewData As String
ListRow = 10: ListColumn = 1: NewDataColumn = 9
While Sheets(1).Cells(ListRow, ListColumn) <> ""
MyNewData = InputBox("Enter the Details for:- " & vbNewLine & vbNewLine & Sheets(1).Cells(ListRow, ListColumn), "Add Data", Sheets(1).Cells(ListRow, NewDataColumn)) 'Get input
If MyNewData <> "" Then Sheets(1).Cells(ListRow, NewDataColumn) = MyNewData 'If input is not empty, use the input
ListRow = ListRow + 1
Wend
End Sub
Dim iRet As Integer
iRet = MsgBox("Are you happy with all the Data entered?" & vbNewLine & vbNewLine _
& "Click 'Yes' to continue and move to next step" & vbNewLine & vbNewLine _
& "Or click 'No' to Re-enter Data and make amendments", vbYesNo, "Check Scores")
If iRet = vbYes Then ‘Next Sub
If iRet = vbNo Then AddData ‘ Start Data entry again
I know I’m asking a lot but any help appreciated.