Results 1 to 14 of 14

Need help with time format and modifying existing code

Threaded View

  1. #1
    Registered User
    Join Date
    08-06-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    8

    Need help with time format and modifying existing code

    Hello there, im using the following code so that I can enter time without colons

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("G:H")) Is Nothing Then
            On Error GoTo FallThrough
            Application.EnableEvents = False
            Dim a As Range
            For Each a In Intersect(Target, Range("G:H"))
                If IsNumeric(a.Value) Then _
                    If a.Value > 1 And a.Value Mod 100 < 60 And Int(a.Value / 100) < 24 Then _
                        a = TimeValue(Int(a.Value / 100) & ":" & Format(a.Value Mod 100, "00"))
            Next a
        End If
    FallThrough:
        Application.EnableEvents = True
    End Sub
    The problem im having is that this code will only allow me to enter hh:mm. I need to enter hh:mm:ss. How would I modify or add to the code to be able to also enter the seconds in my time?

    Im very new to this code thing so yeah im sure this will be a simple thing for some of you that have more advanced knowledge of excel.

    Thanks in advance
    Last edited by jeffreybrown; 03-18-2019 at 05:19 PM. Reason: Please use code tags!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Modifying Existing Code + Find Range Differences
    By jrean042 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-26-2019, 10:09 AM
  2. Modifying existing code to save worksheet
    By Woopwoop in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-26-2015, 08:54 PM
  3. Modifying existing code
    By rhouston08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2015, 06:03 PM
  4. Modifying an existing excel time formula
    By spittingfire in forum Excel General
    Replies: 0
    Last Post: 02-03-2015, 10:04 PM
  5. [SOLVED] Add two more columns, modifying an existing VBA code help.
    By Anka in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 02-17-2013, 01:24 PM
  6. Modifying existing VBA code to find different file name
    By PittsburghEng in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2010, 03:24 PM
  7. Help modifying existing VBA code
    By camcafe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2008, 11:02 AM

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