View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default need a formula to fix time

A formula can't change a cell, so you can't modify A1 with a formula.
In another cell, though, you can use

=IF(LEFT(A1,1)=":","0"&A1,A1)

to prefix a "0" to the text in A1.

With code, you can modify the value in A1:

With Range("A1")
If StrComp(Left(.Text, 1), ":", vbBinaryCompare) = 0 Then
.Value = "0" & .Text
End If
End With

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Wed, 18 Feb 2009 05:37:03 -0800, Rpt_Me4NotBeingSmart
wrote:

Lets say I have time in cell A1 that displays as :59:02. How can I write an
If formula to say If A1 contains :xx:xx, then insert a zero at the
beginning, otherwise do nothing?