Skip to main content

Converting Delimited Text in to Rows.














First of all, I wanna thank Mr. Tony Volko ( An Expert at ExcelForum.com ) to provide this beauty.
The Formula I have used is
=TRIM(MID(SUBSTITUTE("|"&B$3,"|",REPT(" ",255)),ROWS(C$1:C1)*255,255))
Dragged down
Here is the explanation…
Lets start from the inside of the formula first.. Ie.
=SUBSTITUTE("|"&B$3,"|",REPT(" ",255)) Syntax [SUBSTITUTE(text, old_text, new_text)]
which is expanded to
'=SUBSTITUTE("|5|3|4|67|10|45|15","|",REPT(" ",255))
It will SUBSTITUTE the "|" with 255 Spaces and will provide the following Text.

"_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15"
Yes, REPT(" ",255) will provide 255 spaces
Now, here comes the trick, The MID Function.
MID(SUBSTITUTE("|"&B$3,"|",REPT(" ",255)),ROWS(C$1:C1)*255,255) Syntax MID(text, start_num, num_chars)
Expended to

MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", ROWS(C$1:C1)*255,     255)
               Text                                                                                                                          Start_Num         Num_Chars

Now here is a VARIABLE which varies when we drag the formula down Ie ROWS(C$1:C1)
It will work like this..
MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", 1*255,     255)
Will return "_0_Spaces_5_254_Spaces"
MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", 2*255,     255)
Will return "_1_Spaces_3_253_Spaces"
MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", 3*255,     255)
Will return "_2_Spaces_4_252_Spaces"
MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", 4*255,     255)
Will return "_3_Spaces_67_251_Spaces"
MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", 5*255,     255)
Will return "_4_Spaces_10_250_Spaces"
MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", 6*255,     255)
Will return "_5_Spaces_45_249_Spaces"
MID("_255_Spaces_5_255_Spaces_3_255_Spaces_4_255_Spaces_67_255_Spaces_10_255_Spaces_45_255_Spaces_15", 7*255,     255)
Will return "_6_Spaces_15_248_Spaces"

Now Using TRIM Function, the result would be.
5
3
4
67
10
45
15
I hope, I have been able to explain it well .. 
You can also use FORMULA AUDITING to understand it well more. However if you have any queries then don't hesitate , have a comment..

Regards,
Vikas Gautam

File can be downloaded from here..

Comments

Post a Comment

Popular posts from this blog

Automation:- Sending Invitation to Meeting Using Excel VBA

Hello Everyone, In one of the previous post, I wrote about automating Sending Emails using Excel VBA. This time I have come up with a pretty similar code. The code below sends Outlook Meeting Invitations to recipients on one click. here is the Code:- Sub Send_Invite_Auto() Dim olApp As Outlook.Application Dim olApt As AppointmentItem Set olApp = New Outlook.Application 'Creating Outlook Session Set olApt = olApp.CreateItem(olAppointmentItem) 'Creating an Appointment With olApt .Subject = "Enter the subject here." 'Subject .Start = DateAdd("d", 5, Now) 'Enter Date + Time here. .Recipients.Add ("example@gmail.com") 'Recipient Name, Alias, or any other Attribute. .MeetingStatus = olMeeting 'olAppointmentItem with Meeting status olMeeting 'becom

Highlighting Duplicates across multiple sheets

Hi One and All, This time I have come up with some conditional formatting stuff. The aim is to highlight the duplicates across multiple sheets and with in the sheet as well. Assumptions:- 1. I am assuming that sheet names goes on like sheet1, sheet2, sheet3.... 2. The Target Column No. is same in all the sheets. I mean, as in the attached example, its Column A which is being targeted in both sheets.

Making Password Protected PDFs using Excel Vba and PDFtk Tool

Hi Everyone, This time, I have come up a VBA Code to generate Password protected PDFs using Excel. Actually, Excel Vba has .ExportAsFixedFormat Method to generate PDFs but this hasn't any Parameter which takes password to protect the PDFs. So I have used PDFtk Tool which provide Command Line Interface to make PDFs protected using Password. Actually, You can do various things using PDFtk Tool command line varying from creating, merging, Protecting and many other. So Download the PDFtk Tool from the following link:- Download PDFtk Tookit Here are the Steps:- 1. Install the PDFtk Toolkit. 2. Use the following code to Print or Export the Activesheet with a password.