VBA or Code For split the data

Vishaal

Well-known Member
Joined
Mar 16, 2019
Messages
530
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
  2. Web
Hi All,

Thanks in advance,

i have a data

Coloumn 1 Coloumn 2
2305
2054
0654

<tbody>
</tbody>

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

Col 1Col 2Col 3Col 4Col 5
2305235
2054254
0654654

<tbody>
</tbody>

pls provide the VBA code/ formula
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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))
 
Upvote 0
How about

Book1
ABCDEF
1
21230512305
320542054
406540654
Data
Cell Formulas
RangeFormula
B2=MID($A2,COLUMNS($B$1:B1),1)
 
Upvote 0
And what about
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
 
Upvote 0
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))

Rich (BB code):
if(value(mid($a2,columns($b$1:b1),1))=0,"0",text(mid($a2,columns($b$1:b1),1)))
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,492
Messages
6,113,967
Members
448,537
Latest member
Et_Cetera

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top