+ Reply to Thread
Results 1 to 3 of 3

Changing this code

  1. #1
    Neal
    Guest

    Changing this code

    I wanted to know if this was right,
    Dim rCell As Range
    For Each rCell In Range( _
    Range("f1:f1"), _
    Cells(Rows.Count, "e").End(xlUp))
    If rCell.Value <> "" Then
    rCell.FormulaR1C1 = "=(RC[-1] -INT(RC[-1]))*24"
    End If
    Next rCell
    When I run it it takes the info and sets it to zero. I need it to take the
    time in a1 and convert it to military time in b1, could someone please help
    me out, Thanks Neal.

  2. #2
    dmthornton
    Guest

    RE: Changing this code

    You could try something like this

    Replace:
    "=(RC[-1] -INT(RC[-1]))*24"

    With:
    "=TEXT(RC[-1],""h:mm;@"")"

    "Neal" wrote:

    > I wanted to know if this was right,
    > Dim rCell As Range
    > For Each rCell In Range( _
    > Range("f1:f1"), _
    > Cells(Rows.Count, "e").End(xlUp))
    > If rCell.Value <> "" Then
    > rCell.FormulaR1C1 = "=(RC[-1] -INT(RC[-1]))*24"
    > End If
    > Next rCell
    > When I run it it takes the info and sets it to zero. I need it to take the
    > time in a1 and convert it to military time in b1, could someone please help
    > me out, Thanks Neal.


  3. #3
    Don Guillett
    Guest

    Re: Changing this code

    try this instead

    Sub convtomiltime()
    Dim c As Range
    lr = Cells(Rows.Count, "f").End(xlUp).Row
    For Each c In Range("f1:f" & lr)
    If c <> "" Then
    c.Value = c - Int(c) * 24
    c.NumberFormat = "HH:MM"
    End If
    Next c
    End Sub

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Neal" <[email protected]> wrote in message
    news:[email protected]...
    >I wanted to know if this was right,
    > Dim rCell As Range
    > For Each rCell In Range( _
    > Range("f1:f1"), _
    > Cells(Rows.Count, "e").End(xlUp))
    > If rCell.Value <> "" Then
    > rCell.FormulaR1C1 = "=(RC[-1] -INT(RC[-1]))*24"
    > End If
    > Next rCell
    > When I run it it takes the info and sets it to zero. I need it to take the
    > time in a1 and convert it to military time in b1, could someone please
    > help
    > me out, Thanks Neal.




+ 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