Thread
:
need help formatting text in macro
View Single Post
#
4
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
need help formatting text in macro
try
Sub addzeroanddash()
mc = "f"
For i = 1 To Cells(Rows.Count, mc).End(xlUp).Row
If Left(Cells(i, mc), 1) < 0 Then
Cells(i, mc) = "0" & Mid(Cells(i, mc), 1, 1) _
& "-" & Right(Cells(i, mc), 6)
End If
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Daniel M" wrote in message
...
I have a spreadsheet that i scan barcodes into. Some of the barcodes are
old and omit the - in the serial number. I need to format the text to add
it back in. below is an example of the data. Also when the - is omitted it
reads the cell as text instead of general and omits the leading 0.
02-123456
2123456
You see no - and no leading 0. I need to add both back in. Can anyone give
me some help? I have tried a few things but i have another issue that
breaks all of them. Thanks.
dm.
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett