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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,223,634
Messages
6,173,477
Members
452,516
Latest member
archcalx

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