Hello,
I'm creating a user form in excel. I have one cell in which the inputted data needs to conform to strict guidelines (it's an account number field). What I'd like to do is use vba to validate the cell content immediately after it is entered (e.g. as soon as focus is shifted away from the cell), and if it passes validation, it should be formatted in a specific way:
Any questions please let me know, and THANK YOU in advance for your assistance!
I'm creating a user form in excel. I have one cell in which the inputted data needs to conform to strict guidelines (it's an account number field). What I'd like to do is use vba to validate the cell content immediately after it is entered (e.g. as soon as focus is shifted away from the cell), and if it passes validation, it should be formatted in a specific way:
- The cell should contain exactly 9 characters (or 10 if a dash is entered, see step 4) If not, a message should be displayed notifying the user and focus placed back on the offending cell
- The first 3 characters can be alphanumeric, the last 6 must be numeric. If not, a message should be displayed notifying the user and focus placed back on the offending cell)
- Any alpha characters within the first 3 should then be made uppercase
- A dash "-" should be inserted between the first 3 and last 6 if not already present (it should not exist anywhere else in the string)
Any questions please let me know, and THANK YOU in advance for your assistance!