Thread: Help with Macro
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
steve steve is offline
external usenet poster
 
Posts: 576
Default Help with Macro

Tom,

You solution catches the spaces at the beginning of the string
" 131212A"
and results in
" - 131212A"

(see my use of Trim)

--
sb
"Tom Ogilvy" wrote in message
...
Sub HypenateB()
Dim rng as Range, cell as Range
On Error Resume Next
set rng = Columns(2).SpecialCells(xlConstants,xlTextValues)
On Error goto 0
if not rng is nothing then
for each cell in rng
cell.Value = Left(cell,2) & "-" & right(cell,len(cell)-2)
Next
End if
End Sub

Test it on a copy of your data.
--
Regards,
Tom Ogilvy


"Chad Holstead" wrote in message
...
I am not very good at VB and need some help with a
Macro. I have spread sheet that is exported from another
program. We need to reformat the data in Column B. The
data comes into excell like this " 131212A" It needs
to look like this "13-1212A". I have tried the standard
recored macro, however it just replaces the data with the
hard coded value. I need this to be able to handle
diffrent values in column B.

Any ideas would really help, I think this easy, I'm just
not a vb guy.

Thans
Chad