View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default breaking a cell into two cells via VBA program

Hi Jordan,

In Tom's SplitValues Sub, which I prefer to my suggestion, there is a small
typo in the line:

cell.offset(0,1).Value = Right(sStr,len(sStr)-1)


which should read:

cell.offset(0,1).Value = Right(sStr,len(sStr)-2)

---
Regards,
Norman


"Tom Ogilvy" wrote in message
...
Sub SplitValues()
Dim sStr as String, rng as Range
set rng = Range("A1:A2000")
for each cell in rng
sStr = Trim(Cell.Value)
if sStr < "" then
Cell.Value = "'" & Left(sStr,2)
cell.offset(0,1).Value = Right(sStr,len(sStr)-1)
end if
Next
End sub

--
Regards,
Tom Ogilvy