VBA or Code For split the data

Vishaal

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

Thanks in advance,

i have a data

[TABLE="width: 50"]
<tbody>[TR]
[TD]Coloumn 1[/TD]
[TD] Coloumn 2 [/TD]
[/TR]
[TR]
[TD]2305[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2054[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]0654[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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

[TABLE="width: 50"]
<tbody>[TR]
[TD]Col 1[/TD]
[TD]Col 2[/TD]
[TD]Col 3[/TD]
[TD]Col 4[/TD]
[TD]Col 5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2305[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD][/TD]
[TD]5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2054[/TD]
[TD]2[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]0654[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]5[/TD]
[TD]4[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

pls provide the VBA code/ formula
 
Another vba approach if the numbers are all 4-digit. Assumed starting in cell A2.

Code:
Sub Split_Numbers()
    Range("A2", Range("A" & Rows.Count).End(xlUp)).TextToColumns Range("B2"), xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(2, 1), Array(3, 1))
End Sub
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,750
Messages
6,180,740
Members
452,996
Latest member
nelsonsix66

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