Consulting

Results 1 to 10 of 10

Thread: Restrict Cell entry to minutes and seconds only

  1. #1

    Restrict Cell entry to minutes and seconds only

    How can I restrict cell entry to

    minutes and seconds

    or

    hour minutes and seconds

    using : seperator ??

    any help??

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    You could use Data VAlidation and set the cell as Time!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
     With Range("Talk_Time")
                        cell = .Cells(1, 1).Address(False, False)
                        .Locked = False
                        .Validation.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:=xlGreater, _
                        Formula1:="=AND(" & cell & ">=TIME(0,0,1)," & cell & "<=TIME(23,59,59))"
                        .Validation.IgnoreBlank = False
                        .Validation.ErrorTitle = "Time Error"
                        .Validation.ErrorMessage = "Please Enter Minutes & Seconds in this format 23:59"
                        .Validation.ShowError = True
                        .WrapText = False
                        .ColumnWidth = 7
                        .Interior.ColorIndex = 43
                        .EntireColumn.Hidden = False
                    End With
    I currently use this code but it always turns the time to 1??

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What do you mean by it always turns to 1, it works for me, including making the cells green.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5

    update

    It works for me sometimes, but more often than not it shows a value of 1

    for example talk time was 1hr 20munites and 9 seconds.

    So I input 1:20:09
    It displays 0
    in the formula bar it show 0.0556597222222222

    im confused.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That time works fine for me.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7

    Update?

    why doesnt it work for me?

  8. #8
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I couldn't get it to fail either.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Hmmmm, do you have custom formatting set up for the cell?
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  10. #10

    Thanks

    Not as far as I am aware, but there maybe some other script within another module that might be chaning the formatting. I will check and get back

Posting Permissions

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