The ChartObject on my worksheet displays trend lines. The user controls the period of the rolling averages by entering a number between 3 and 21 in an ActiveX TextBox. A TextBox_Change event handler can check whether each character is a digit as it’s entered but VBA can’t check whether the entry is within range and update the chart until the entry is complete. I can’t figure out how VBA can detect the Enter key has been pressed. The Enter key does NOT appear to raise KeyPress or LostFocus events. In fact, I can’t make it ever any raise any events.
There are other ways the user could indicate the entry is complete, of course: Select another control or a worksheet cell which does raise a LostFocus event or I could add a Command Button control next to the TextBox labelled “Update”. For that matter, the user could just enter the value in a worksheet cell and Data Validation could check it. But pressing Enter to indicate an entry is complete is so universal in Excel, I just wonder if I’m not missing something obvious?