Changing this code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
You could try something like this

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

With:
"=TEXT(RC[-1],""h:mm;@"")"
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top