View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Arne Hegefors Arne Hegefors is offline
external usenet poster
 
Posts: 244
Default Keeping 0 at beginning

Thanks! My problem is that the data is retrieved from another program and is
too much data to change by hand. Might come up with something though based on
your idea. Thanks very much!

"Myles" skrev:


One way. Before you ran your code, make sure all the numeric blocks
starting with 0 are prefixed with an apostrophe('). Eg "ACGB 4.75 0311"
becomes "ACGB 4.75 '0311". The following code can achieve that:


Sub Primer()
Dim c As Range
Dim i As Integer

For Each c In Range("a1:a" & Cells(Rows.Count, "a").End(xlUp).Row)
'assuming data is inCol A
For i = 1 To Len(c)
If Mid(c, i, 1) = Chr(32) And Mid(c, i + 1, 1) = "0" Then
k = k & Mid(c, i, 1) & Chr(39)
Else
k = k & Mid(c, i, 1)
End If
Next
c.Value = k
k = ""
Next
End Sub


--
Myles
------------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=573795