Thank you for buying the book.
Just to get things started, I revised your code with a few changes:
⢠The Alert style is Stop (instead of Information as you had it), because you intend to only accept valid whole numbers within a range of 10250 to 10720.
⢠I added the Delete statement in case you run the macro more than once upon cell D1 which, if it already has data validation assigned to it, cannot otherwise accept a data validation installation without its current data validation deleted. This results in a run time error otherwise, or, in long macros which yours might be, no such notice and that may have been why it looked to you that the macro was skipping over the portion you posted.
⢠I don't know what you mean by "that cell/column is not filled in in the completed worksheet." The only cell you refer to is cell D1, so that is what I refer to in the below modification which does work on cell D1.
⢠Regarding "I don't get an input box asking me to enter the bank account GL #.", I think you mean the Input Message (there are VBA objects called Input Boxes which I doubt you meant to refer to in this case). With the below modified code, when you select cell D1 you will see the instructions appear.
⢠I rewrote your error message for a clearer meaning to the user.
⢠You didn't ask about this, so just saying, because you allow for a rather lengthy possibility of whole numbers that can fall between and including 10250 and 10720, which is fine, you won't see a drop down list of allowable entries such as if your Operator was of the List type rather than the Between type. But the popup (Input) message and the error message will cover the instructions for that to the user.
Here's the modified code in a macro for you to test, which worked for me:
Code:
Sub Test()
With Range("D1").Validation
.Delete
.Add Type:=xlValidateWholeNumber, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="10250", Formula2:="10720"
.IgnoreBlank = True
.InputTitle = "Input Bank Account GL Number"
.InputMessage = "Enter the bank account GL account number between 10250 and 10720 (e.g. 10710)."
.ErrorTitle = "Input Bank Account GL Number"
.ErrorMessage = "Please enter a 5-digit whole number" & Chr(10) & "between 10250 and 10720"
.ShowError = True
End With
End Sub