Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- 411K Members
- 5,461 Online
- 466K Conversations

- Home
- :
- Excel
- :
- General Discussion
- :
- Text to Columns for Multiple Columns at Once

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

SOLVED
## Text to Columns for Multiple Columns at Once

Conversation Options

- Subscribe to RSS Feed
- Mark Conversation as New
- Mark Conversation as Read
- Pin this Conversation for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-17-2019 02:18 PM

I have maybe 100 columns that have all similar info like "number X". All of these columns need to be split into "number" and "X". So far I have been using the text to columns feature for each individual column. I am wondering, is there a way to split all of these at once? Thanks in advanced!

Example:

|A |B |C |D | to--> |A |B |C |D |

|1 X| |2 Y| | | 1 | X | 2 | Y |

Labels:

8 Replies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-17-2019 07:48 PM

SolutionIf you already have blank columns next to your data, you can use a simple macro to automate your text to column conversions. I suggest recording the conversion of one column, then generalizing the recorded macro because the text to columns method is a little complicated.

The code below was based on a recorded macro. It assumes you select the cells to be converted, that every other column will be converted, and that you already have the necessary blank columns.

Sub TextToColumnator() Dim rg As Range Dim i As Long, n As Long Application.ScreenUpdating = False Application.DisplayAlerts = False Set rg = Selection n = rg.Columns.Count For i = 1 To n Step 2 rg.Columns(i).TextToColumns Destination:=rg.Cells(1, i), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _ Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _ :=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True Next Application.DisplayAlerts = True End Sub

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-18-2019 01:17 AM

Hi,

There is another way of splitting the columns in excel using Left() & Right() functions.

If the formation of your data is somehow uniform you can use these functions and easily split all columns in one go.

I have attached a sample file just for understanding purpose.

You may also share your file, so more solutions can be suggested.

Thanks,

Tauqeer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-23-2019 08:50 AM

@tauqeeracmaI was hoping this would work since it's easier, however my data is all over the place in length. But thanks for the response! I never knew this was a function before.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-24-2019 10:04 AM

"however my data is all over the place in length"

That's why you should always post a sample workbook with data illustrating the problem. Then instead of getting a suggestion that solves the question you asked, you get one that addresses the specifics of your actual data.

If the columns are of different length, that is easily addressed with a tweak to the macro. If the blank columns between your data don't exist, that can also be addressed. If you may have more than one delimiter in each cell, even that can also be addressed (though with somewhat more difficulty).

Brad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-25-2019 11:08 AM

Is this what you mean? I'm sorry, I'm new to this forum and didn't see a place to attach examples, so I copied and pasted this in. I can easily add in the spaces between data columns, but I get stuck on separating the data from there (separating the number including [] from the letter). So far a recorded macro is working best, but I haven't been able to make it work outside specific columns. I'm still trying to learn how macros work to fully understand how to edit the recorded macro, so I'm pursuing that for now. Any help or how-to video references are appreciated. :)

1 | 3 | 5 | 7 | |

Raw Data | 0.072 J | [0.0005] U | [0.0005] U | [0.0005] U |

0.0002 J | [0.00055] U | [0.05] U | [0.0005] U | |

[0.00025] U | [0.007] U | [0.0005] U | [0.005] U | |

[0.0025] U | [0.0005] U | [0.0005] U | [0.0005] U | |

[0.000275] U | [0.0025] U | [0.005] U | [0.0005] U | |

[0.00025] U | [0.005] U | 0.05 J | [0.0005] U | |

[0.005] U | [0.0005] U | [0.0005] U | [0.005] U | |

1 | 2 | 3 | 4 | |

Add Spaces w sort | 0.072 J | [0.0005] U | ||

0.0002 J | [0.00055] U | |||

[0.00025] U | [0.007] U | |||

[0.0025] U | [0.0005] U | |||

[0.000275] U | [0.0025] U | |||

[0.00025] U | [0.005] U | |||

[0.005] U | [0.0005] U |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-25-2019 11:19 AM

Oh wow! I got the macro you shared to work, thank you! I was initially trying to record my own macro instead, which I'd still like to figure out. But for my current purposes, yours works exactly how I need!

:)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-25-2019 02:52 PM

It is also possible to use a macro to insert the blank columns.

Select your data, then run the macro. It will add blank columns after each column in your selection.

Sub InsertBlankColumns() Dim rg As Range Dim i As Long, n As Long Application.ScreenUpdating = False Set rg = Selection.EntireColumn n = rg.Columns.Count For i = n To 1 Step -1 rg.Columns(i + 1).EntireColumn.Insert Next End Sub

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Related Conversations

flashing a white screen while open new tab

cntvertex
in
Discussions
on
10-05-2019
23.2K
Views

10 Likes

13 Replies

Stable version of Edge insider browser

HotCakeX
in
Discussions
on
10-12-2019
24.7K
Views

1 Likes

35 Replies

What is Canary ring in Windows insider program? and how do we get them?

HotCakeX
in
Windows Insider Program
on
09-27-2019
11.1K
Views

0 Likes

9 Replies

How to Prevent Teams from Auto-Launch

chenrylee
in
Microsoft Teams
on
06-27-2019
137K
Views

6 Likes

28 Replies

PacketMon Components are not loading in WAC 1909

HotCakeX
in
Windows Admin Center
on
09-24-2019
1,659
Views

0 Likes

2 Replies

Share

Popular

Learning Resources

Programs

Values

- Contact us
- Privacy & cookies
- Terms of use
- Trademarks
- About our ads
- © Microsoft