ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MsgBox Format(3.767, "[hh]:mm") (https://www.excelbanter.com/excel-programming/435182-msgbox-format-3-767-%5Bhh%5D-mm.html)

David

MsgBox Format(3.767, "[hh]:mm")
 
On a worksheet cell, value = 3.767 and formatted "[hh]:mm"
I get 90:23 (90 hours and 23 mins)
I want to return "90:23" with VBA but I get ":01"
When i try MsgBox Format(3.767, "hh:mm") - no square brackets
I get "18:24" (the remaining hours over a multiple of 24 as expected)
Any advice will be appreciated

Mike H

MsgBox Format(3.767, "[hh]:mm")
 
Hi,

Try this

myval = 3.767
MsgBox WorksheetFunction.Text(myval, "[hh]:mm")

Mike

"David" wrote:

On a worksheet cell, value = 3.767 and formatted "[hh]:mm"
I get 90:23 (90 hours and 23 mins)
I want to return "90:23" with VBA but I get ":01"
When i try MsgBox Format(3.767, "hh:mm") - no square brackets
I get "18:24" (the remaining hours over a multiple of 24 as expected)
Any advice will be appreciated


David

MsgBox Format(3.767, "[hh]:mm")
 
Thanks Mike, worked a treat

"Mike H" wrote:

Hi,

Try this

myval = 3.767
MsgBox WorksheetFunction.Text(myval, "[hh]:mm")

Mike

"David" wrote:

On a worksheet cell, value = 3.767 and formatted "[hh]:mm"
I get 90:23 (90 hours and 23 mins)
I want to return "90:23" with VBA but I get ":01"
When i try MsgBox Format(3.767, "hh:mm") - no square brackets
I get "18:24" (the remaining hours over a multiple of 24 as expected)
Any advice will be appreciated



All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com