+ Reply to Thread
Results 1 to 3 of 3

Cell format changing on the fly

  1. #1
    Registered User
    Join Date
    01-12-2006
    Posts
    4

    Cell format changing on the fly

    Is there a way to format a cell so that if you enter a time, such as entering :30 into A3, and having Excel automatically changing that value to decimal, in this case, .50?

    So if I enter :30, hit enter, and it changes to .50 in the same cell?

    Thanks!

  2. #2
    Registered User
    Join Date
    01-12-2006
    Posts
    4
    Anybody have any ideas?

  3. #3
    vezerid
    Guest

    Re: Cell format changing on the fly

    Bellz,
    First of all, (at least my version of) Excel does not accept :30 as
    time. It is accepted as text.

    With this said, your job can be done with an event macro:

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
    Range)
    If Left(Target.Value, 1) = ":" And IsNumeric(Mid(Target.Value, 2,
    Len(Target.Value))) Then
    Target.Value = CInt(Mid(Target.Value, 2, Len(Target.Value))) / 60
    End If
    End Sub

    Press Alt+F11 to bring up the VBA IDE.
    At the top left is the Project Explorer window.
    Under the workbook you want to work with there is the icon
    ThisWorkbook.
    Double-click the icon to bring up the VBA code page for the workbook.
    Paste the above code.

    HTH
    Kostis Vezerides


+ 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