# Thread: VBA or Code For split the data Thanks:  1 Post #5330529 (1) Likes: 0

1. ## VBA or Code For split the data

Hi All,

i have a data

 Coloumn 1 Coloumn 2 2305 2054 0654

now i want to split, but when we split the data, "0" is not coming

 Col 1 Col 2 Col 3 Col 4 Col 5 2305 2 3 5 2054 2 5 4 0654 6 5 4

pls provide the VBA code/ formula

2. ## Re: VBA or Code For split the data

Given first cell (2305) is in A2 try this in B2 and copy across:

IF(VALUE(MID(\$A2,COLUMNS(\$B\$1:B1),1))=0,"",MID(\$A2,COLUMNS(\$B\$1:B1),1))

3. ## Re: VBA or Code For split the data

Thanks Tyija1995

4. ## Re: VBA or Code For split the data

Still 0 is not coming

5. ## Re: VBA or Code For split the data

ABCDEF
1
21230512305
320542054
406540654

Data

Worksheet Formulas
CellFormula
B2=MID(\$A2,COLUMNS(\$B\$1:B1),1)

6. ## Re: VBA or Code For split the data

Code:
```Sub test()
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lr
For j = 1 To Len(Cells(i, 1))
Cells(i, j).Offset(0, 1) = Mid(Cells(i, 1), j, 1)
Next
Next
End Sub```

7. ## Re: VBA or Code For split the data

Originally Posted by tyija1995
given first cell (2305) is in a2 try this in b2 and copy across:

If(value(mid(\$a2,columns(\$b\$1:b1),1))=0,"",mid(\$a2,columns(\$b\$1:b1),1))
Code:
`if(value(mid(\$a2,columns(\$b\$1:b1),1))=0,"0",text(mid(\$a2,columns(\$b\$1:b1),1)))`

8. ## Re: VBA or Code For split the data

thanks Fluff
bro,

great its working

9. ## Re: VBA or Code For split the data

its easy and fast

10. ## Re: VBA or Code For split the data

You're welcome & thanks for the feedback