+ Reply to Thread
Results 1 to 6 of 6

Force a . separator

  1. #1
    Registered User
    Join Date
    12-11-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Force a . separator

    Hi all, I am very new to Excel. I have made a holiday planner which seems to work ok.
    I am now putting a few safetys into it. What I want to do is when a user enters a number of hours into a data form box in the wrong format, say 8,5 instead of 8.5 a error box comes up that will not let the operation continue until the . is present. Can anyone assist please
    Im sorry this is a bit long wnided but Im not sure on the correct termonology yet, but im learning. Thanks in advane.
    PS are there any banks of code that I could view and take the bits I think will work for me,or re-work the code to suit my needs, Thanks again Mike G.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Force a . seperator

    Hello MikeGonza,

    Welcome ot the Forum!

    The answer depends on what type of "form" you are referring to. Is this a worksheet or a VBA UserForm?
    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 Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Force a . seperator

    You can use data validation for this possibly.

    Go to Data|Validation

    Select Decimal from the Allow menu

    Select Between from the Data menu

    Enter a Min and Max value

    You can then click the Input and Error tabs to customize the input prompt and Error alert.

    This will force the user to use a "real number" between your Min and Max and can include whole numbers or decimals, but not commas...
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    12-11-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Force a . seperator

    Quote Originally Posted by Leith Ross View Post
    Hello MikeGonza,

    Welcome ot the Forum!

    The answer depends on what type of "form" you are referring to. Is this a worksheet or a VBA UserForm?
    Yes thanks Leith
    I enter the Hours into a user form so the Data validation answer below would work, but I need to put it into my code when I exit the user form and enter the data into the cell.
    any thoughts?

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Force a . seperator

    Hello Mike,

    In the hours TextBox Exit event you can set Cancel = True to force the user back to the TextBox. You can first display a message using the MsgBox to alert the user the entry is not valid.

  6. #6
    Registered User
    Join Date
    12-11-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Force a . seperator

    Quote Originally Posted by NBVC View Post
    You can use data validation for this possibly.

    Go to Data|Validation

    Select Decimal from the Allow menu

    Select Between from the Data menu

    Enter a Min and Max value

    You can then click the Input and Error tabs to customize the input prompt and Error alert.

    This will force the user to use a "real number" between your Min and Max and can include whole numbers or decimals, but not commas...
    Thanks NBVC
    This would work fine, but the Hours are being entered into a VBA user form, so I need this to work in my exit code as the data is entered into the spreadsheet, see my answer above. Thankyou very much for the quick response thou. MikeG

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1