Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default Convert to minutes and seconds

Code (as follows) calculates, and places a value in a cell.
The value is in Minutes, and rounded to 2 decimal places:

With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
End With

I cannot find a way to display the value in "mm:ss" format
.....preferably also the seconds to 2 decimal places.

Is this possible, please?

Regards.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Convert to minutes and seconds

With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Numberformat = "[mm]:ss.00"
End With

This assumes your equation puts a legitimate time value in the cell. If
not, make it so.

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Code (as follows) calculates, and places a value in a cell.
The value is in Minutes, and rounded to 2 decimal places:

With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
End With

I cannot find a way to display the value in "mm:ss" format
....preferably also the seconds to 2 decimal places.

Is this possible, please?

Regards.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default Convert to minutes and seconds

Yup, had to legitimise the value, so:

For Each C In .Range("B5:DV104")
With C
.Value = (Range("A" & C.Row).Value * 60) / _
(Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Value = C.Value / 24 / 60
'my mistake...decimal places confuse the result
' .NumberFormat = "[mm]:ss.00"
.NumberFormat = "[mm]:ss"
End With
Next

Now, if the revised value is 60:00, can I introduce an
If statement to convert the cell format to something like
"[h]:mm:ss" ?

Regards and thanks.

"Tom Ogilvy" wrote in message
...
With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Numberformat = "[mm]:ss.00"
End With

This assumes your equation puts a legitimate time value in the cell. If
not, make it so.

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Code (as follows) calculates, and places a value in a cell.
The value is in Minutes, and rounded to 2 decimal places:

With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
End With

I cannot find a way to display the value in "mm:ss" format
....preferably also the seconds to 2 decimal places.

Is this possible, please?

Regards.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Convert to minutes and seconds

For Each C In .Range("B5:DV104")
With C
.Value = (Range("A" & C.Row).Value * 60) / _
(Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Value = C.Value / 24 / 60
if hour(c.Value < 1) then
'my mistake...decimal places confuse the result
' .NumberFormat = "[mm]:ss.00"
.NumberFormat = "[mm]:ss"
else
.NumberFormat = "[hh]:mm:ss"
end if
End With
Next

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Yup, had to legitimise the value, so:

For Each C In .Range("B5:DV104")
With C
.Value = (Range("A" & C.Row).Value * 60) / _
(Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Value = C.Value / 24 / 60
'my mistake...decimal places confuse the result
' .NumberFormat = "[mm]:ss.00"
.NumberFormat = "[mm]:ss"
End With
Next

Now, if the revised value is 60:00, can I introduce an
If statement to convert the cell format to something like
"[h]:mm:ss" ?

Regards and thanks.

"Tom Ogilvy" wrote in message
...
With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Numberformat = "[mm]:ss.00"
End With

This assumes your equation puts a legitimate time value in the cell. If
not, make it so.

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Code (as follows) calculates, and places a value in a cell.
The value is in Minutes, and rounded to 2 decimal places:

With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
End With

I cannot find a way to display the value in "mm:ss" format
....preferably also the seconds to 2 decimal places.

Is this possible, please?

Regards.








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default Convert to minutes and seconds

if hour(c.Value < 1) then ....is the key

Regards and thanks.

"Tom Ogilvy" wrote in message
...
For Each C In .Range("B5:DV104")
With C
.Value = (Range("A" & C.Row).Value * 60) / _
(Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Value = C.Value / 24 / 60
if hour(c.Value < 1) then
'my mistake...decimal places confuse the result
' .NumberFormat = "[mm]:ss.00"
.NumberFormat = "[mm]:ss"
else
.NumberFormat = "[hh]:mm:ss"
end if
End With
Next

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Yup, had to legitimise the value, so:

For Each C In .Range("B5:DV104")
With C
.Value = (Range("A" & C.Row).Value * 60) / _
(Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Value = C.Value / 24 / 60
'my mistake...decimal places confuse the result
' .NumberFormat = "[mm]:ss.00"
.NumberFormat = "[mm]:ss"
End With
Next

Now, if the revised value is 60:00, can I introduce an
If statement to convert the cell format to something like
"[h]:mm:ss" ?

Regards and thanks.

"Tom Ogilvy" wrote in message
...
With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Numberformat = "[mm]:ss.00"
End With

This assumes your equation puts a legitimate time value in the cell.
If
not, make it so.

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Code (as follows) calculates, and places a value in a cell.
The value is in Minutes, and rounded to 2 decimal places:

With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
End With

I cannot find a way to display the value in "mm:ss" format
....preferably also the seconds to 2 decimal places.

Is this possible, please?

Regards.












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Convert to minutes and seconds

Must have been a typo. Should be

if hour(c.Value) < 1 then




--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
if hour(c.Value < 1) then ....is the key

Regards and thanks.

"Tom Ogilvy" wrote in message
...
For Each C In .Range("B5:DV104")
With C
.Value = (Range("A" & C.Row).Value * 60) / _
(Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Value = C.Value / 24 / 60
if hour(c.Value < 1) then
'my mistake...decimal places confuse the result
' .NumberFormat = "[mm]:ss.00"
.NumberFormat = "[mm]:ss"
else
.NumberFormat = "[hh]:mm:ss"
end if
End With
Next

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Yup, had to legitimise the value, so:

For Each C In .Range("B5:DV104")
With C
.Value = (Range("A" & C.Row).Value * 60) / _
(Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Value = C.Value / 24 / 60
'my mistake...decimal places confuse the result
' .NumberFormat = "[mm]:ss.00"
.NumberFormat = "[mm]:ss"
End With
Next

Now, if the revised value is 60:00, can I introduce an
If statement to convert the cell format to something like
"[h]:mm:ss" ?

Regards and thanks.

"Tom Ogilvy" wrote in message
...
With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
.Numberformat = "[mm]:ss.00"
End With

This assumes your equation puts a legitimate time value in the cell.
If
not, make it so.

--
Regards,
Tom Ogilvy


"Stuart" wrote in message
...
Code (as follows) calculates, and places a value in a cell.
The value is in Minutes, and rounded to 2 decimal places:

With C
.Value = (Range("A" & C.Row).Value * 60) _
/ (Cells(3, C.Column).Value / 60)
.Value = Round(C.Value, 2)
End With

I cannot find a way to display the value in "mm:ss" format
....preferably also the seconds to 2 decimal places.

Is this possible, please?

Regards.












Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert text entered as minutes/seconds to minutes Kathie Excel Worksheet Functions 1 May 6th 10 05:05 AM
Need to convert Minutes:Seconds format to minutes with seconds con Cliff Excel Worksheet Functions 3 June 18th 09 05:22 AM
I need to convert 157.25 minutes, into hours, minutes and seconds. Al Excel Discussion (Misc queries) 2 March 11th 09 09:04 AM
Convert "Time Interval" in "hours : minutes : seconds" to seconds Ianukotnorth New Users to Excel 7 May 8th 05 08:11 PM
Convert seconds to minutes and seconds in excel anonymous Excel Worksheet Functions 3 December 25th 04 08:38 PM


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"