I'd like to delimit my text in column B (like text-to-columns feature) without having to pre-allocating free space on the right side.

Posted on 2016-11-18
Last Modified: 2016-11-20
Hi Experts,

I would like to use VBA to help me perform the following task:


A                     B                                                C
Invoice No.   Model Name.                           Cust Name
0001              BMW X5,Audi A4                     Lisa Marie Presley
0002              Volvo S80, Jaguar XJ,Audi A6  Johnny Depp
0003              Acura NSX                                 Angelina Jolie

I need a script to automatically sort the model of each invoice.


A                     B                                                C
Invoice No.   Model Name.                           Cust Name
0001              Audi A4, BMW X5,                     Lisa Marie Presley
0002              Audi A6, Jaguar XJ,Volvo S80   Johnny Depp
0003              Acura NSX                                  Angelina Jolie

And then immediately delimit text (aka Convert Text to Columns) in column B without having to overwriting data in column C.
Any idea how to write a script module to perform the above?

Please advice.

Thank you.

Question by:Brian Smith
  • 3
LVL 19
ID: 41894003
where do you want the extra data from column B to go? Why not just move what is in column B to the last column and use Text-to-Columns?

Author Comment

by:Brian Smith
ID: 41894015
Hi Crystal,

Thank you for your response and sorry for the confusion,

Allow me clarify this further. Below is the desired output that I am trying to achieve (in full/semi-automation):

A                     B                        C                D                 E
Invoice No.   Model Name                                          Cust Name  
0001              Audi A4              BMW X5                       Lisa Marie Presley
0002              Audi A6,             Jaguar XJ   Volvo S80   Johnny Depp
0003              Acura NSX                                               Angelina Jolie

Once this is achieve, i will need to run  a macro template to auto pivot out the desired monthly table & chart before passing to other dept for further actions.

P/S: The data showing here is just a simplified version of mock-run data to illustrate and for better/easier to understand. But in reality, the xls data file is actually sharing among multiple dept and consisting hundreds of columns and thousands rows of value (and I am not allow  to make any modification in row/column format, otherwise the macro template will not work and will also create confusion to other dept).

Hope I had answer your question.

Thanks again.

Author Comment

by:Brian Smith
ID: 41894028
Additional Info:

I had tried the VBA script suggested on this Youtube tutorial:

However, the  example given is this video is with an assumption that, the value of sSeparotor (e.g. dash, comma, etc) of every row  is always the same.

So, it doesn't apply to my case scenario, where the total number of comma in every row of column B is not fix.

It can be up to any value, depends on how many cars has ordered by the particular customer in that specific invoice.
LVL 21

Accepted Solution

Ejgil Hedegaard earned 500 total points
ID: 41894422

Author Closing Comment

by:Brian Smith
ID: 41894955
Thank you so much Ejgil! it is works like a charm!  :)

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now