title: How do I switch from PM/AM to 24h in Excel with VBA
body: <p>as 4 Leave Cover has stated his Problem with switching 24h to PM/AM - <a href="https://stackoverflow.com/questions/16681900/excel-vba-timevalue-format-hhmm-am-pm">EXCEL VBA Timevalue format (hh:mm am/pm)</a></p>
  
  <p>I have exactly the opposite problem:</p>
  
  <p>I use following code (t = 1,39)</p>
  
  <pre><code>t = wks.Range("G1").Value / 1440
  wks.Range("I1").Value = Format(t, "hh:mm:ss")
  </code></pre>
  
  <p>which gives me 00:01:23 in the formula text field, but in cell it is formatted as 12:01:23 AM. The problem is: In cell I want it to be formatted as 00:01:23 as well. If possible - I would even like to have it just minutes and seconds. - but "nn:ss" gives me 1:23:00 AM and "mm:ss" gives me 12:23:00 PM.</p>
  
  <p>I have also tried a TimeSerial-Function but the output in cell is basically the same as mentioned above- In opposite to debug.print however, which gives me the desired results - not in a cell though:</p>
  
  <pre><code>Public Function FromTimeToDecimal(ByVal t As Double) As Date
  FromTimeToDecimal = TimeSerial(0, Fix(t), (t - Fix(t)) * 60)
  End Function
  </code></pre>
  
  <p>So basically I am out of clue at the moment</p>
  
  <p>(country setting is set to Germany - in case that matters)</p>