Hello,
I am looking for a VBA Macros to force user to enter numbers of numbers with hyphen in range F3:I3.
For example: 1298 or 1298-2 or 1298-4
If a user did not enter properly message will be displayed for wrong entry.
Hello,
I am looking for a VBA Macros to force user to enter numbers of numbers with hyphen in range F3:I3.
For example: 1298 or 1298-2 or 1298-4
If a user did not enter properly message will be displayed for wrong entry.
Try this in the Sheet module:
![]()
Please Login or Register to view this content.
Directions for running the routine(s) just supplied
Copy the code to the clipboard
Press ALT + F11 to open the Visual Basic Editor.
Save your Workbook As Macro-Enabled
Click on the appropriate sheet
Type "Option Explicit" then paste the code under it
And, you should be ready to go
![]()
Last edited by xladept; 09-27-2013 at 05:12 PM.
If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)
You can't do one thing. XLAdept
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin
@ xladept,
Makes perfectly sense to me.
I would, however add:
Regards![]()
Please Login or Register to view this content.
Last edited by Winon; 09-27-2013 at 05:35 PM. Reason: Syntax
Please consider:
Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
FYI -
When working with Change or SelectionChange events, you need to be careful not to create a cascade event failure. This happens when changing a cell's value in the event. It will call the event again. This can happen ad inifinitum causing a stack overflow error. for example...
A better and more robust approach would be...
![]()
Please Login or Register to view this content.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
@ Leith Ross,
Oops, I missed that very important bit.
I shall blame it on me, being way pass my bedtime.
Thank you, for coming to the rescue, Leith!
Signing off for now, to prevent any further blunders.
Regards
@Leith - Can you explain why the placing of the disable events..enable events is poor in my code??![]()
Hello xladept,
What you did in your code will work. The end user can often outsmart the code writer by generating an unexpected error. It has happened to me in the past and the user later contacts me that Excel is not working. Often times, a little prevention will make the user swear by you instead of at you.
Thanks to all of your xladept, Winon & Leith Ross.
Mr. Leith Ross it works for me as i want. Thank you all of your for your spending time and help for me. i really appreciate.
You're welcome!![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks