Hello All,
I have been searching and have found several topics on validating textboxes on userforms, but have not been able to find an answer and hoping someone can assist.
I have a userform with several textboxes. In my instance, I have a textbox that the user enters a year. I need to be sure that the year entered is equal to or greater than a year in a specific cell on the worksheet. If the year is less than that year, I want to capture that occurrence, display an error msg, delete the user's entry and set focus back on that text box.
I have tried this ...
But that does not work. I use the AfterUpdate event because I want to run the application "update_controlpanel" after the user updates the textbox ... that macro updates several userform labels.
The cell range, "incr2_earlystart", contain the 4-digit numeric field for the year I am trying validate against.
I did try the textbox event "Change" ... but that did not work either.
Appreciate any assistance.
Thanks,
Steve
I have been searching and have found several topics on validating textboxes on userforms, but have not been able to find an answer and hoping someone can assist.
I have a userform with several textboxes. In my instance, I have a textbox that the user enters a year. I need to be sure that the year entered is equal to or greater than a year in a specific cell on the worksheet. If the year is less than that year, I want to capture that occurrence, display an error msg, delete the user's entry and set focus back on that text box.
I have tried this ...
Code:
Private Sub dues2_yearstextbox_AfterUpdate()
If dues2_yearstextbox.Value < Range("incr2_earlystart").Value Then
MsgBox "Please enter a value less than or equal to the earliest start year."
dues2_yearstextbox.Value = ""
dues2_yearstextbox.SetFocus
Else: End If
Application.Run ("update_controlpanel")
End Sub
But that does not work. I use the AfterUpdate event because I want to run the application "update_controlpanel" after the user updates the textbox ... that macro updates several userform labels.
The cell range, "incr2_earlystart", contain the 4-digit numeric field for the year I am trying validate against.
I did try the textbox event "Change" ... but that did not work either.
Appreciate any assistance.
Thanks,
Steve
Last edited: