How To Format a Cell as "[h]:mm" ????

  • Thread starter Thread starter joshuaand
  • Start date Start date
J

joshuaand

Hi I am trying to format a cell as "[h]:mm" programatically using VB
but cant seem to do it.

I want to add up a bunch of hours, but by default it is setting th
format to "h:mm", which is NOT what I want.

anyones help is appreciated
 
Range("A1").NumberFormat = "[h]:mm"

You need to learn the Macro Recorder. It's very useful for capturing these
sorts of things.

From Excel's menu, Tools | Macro | Record New Macro...
When you've finished, click the Stop button.
 
Sub TestFormat()
SetFormat Range("C5:E10")
End Sub

Sub SetFormat(Target As Range)
Target.NumberFormat = "[H]:mm"
End Sub


Patrick Molloy
Microsoft Excel MVP
 

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