Dynamic Text To Column

Warryk

New Member
Joined
Aug 29, 2015
Messages
3
I'm trying to create a dynamic text to column but i have no idea how to do this. Basically I have a cell that will contain quantity and sizes of apparel and may look something like this:
20/s 13/M 14/L

I can do a text to column that will pull this information out into individual cells to look like this:

20
S
13
M
14
L

<tbody>
</tbody>

That part was easy, and having the data like that allows me to do a lot of other things with it that I need to. The problem is, the original cell's values may change and I don't want to have to redo the text to column feature every time that happens. I'll be inputting size data like this on 20 or more lines as well, so I'd much rather have something that updates automatically.

Any suggestions?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Assuming the column you will be putting the data in is Column A, give this event code procedure a try...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Rng As Range, Cell As Range, Txt As String
  Set Rng = Intersect(Target, Columns("A"))
  If Not Rng Is Nothing Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    For Each Cell In Rng
      Txt = Cell.Value
      Cell.Offset(, 1).Resize(, Columns.Count - 1).ClearContents
      Cell.Offset(, 1) = Application.Trim(Replace(Txt, "/", " "))
      Cell.Offset(, 1).TextToColumns Cell.Offset(, 1), xlDelimited, , , 0, 0, 0, True
    Next
    Application.EnableEvents = True
    Application.ScreenUpdating = True
  End If
End Sub

HOW TO INSTALL Event Code
------------------------------------
If you are new to event code procedures, they are easy to install. To install it, right-click the name tab at the bottom of the worksheet that is to have the functionality to be provided by the event code and select "View Code" from the popup menu that appears. This will open up the code window for that worksheet. Copy/Paste the event code into that code window. That's it... the code will now operate automatically when its particular event procedure is raised by an action you take on the worksheet itself. Note... if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Warryk,

In the light of Rick's above code you may not wish to use a formula but here is a possibility of such....

Excel 2007
ABCDEFG
220/s 13/M 14/L20s13M14L
3201232499/sssssssvs 1399999v/Mmmmmmmmv 149999999v/Lllllllllllllv201232499sssssssvs1399999vMmmmmmmmv149999999vLllllllllllllv
Sheet2
Cell Formulas
RangeFormula
B2=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A2,"/", " ")," ",REPT(" ",99)),(COLUMNS($B1:B1)-1)*99+1,99))
 
Upvote 0
Warryk,

In the light of Rick's above code you may not wish to use a formula but here is a possibility of such....
Excel 2007
ABCDEFG
220/s 13/M 14/L20s13M14L
3201232499/sssssssvs 1399999v/Mmmmmmmmv 149999999v/Lllllllllllllv201232499sssssssvs1399999vMmmmmmmmv149999999vLllllllllllllv

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
B2=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A2,"/", " ")," ",REPT(" ",99)),(COLUMNS($B1:B1)-1)*99+1,99))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

This is exactly what i was looking for. Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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