Solved

Excel, parse strings into columns  from a list of offsets (columns widths) and column names

Posted on 2013-01-30
5
342 Views
Last Modified: 2013-01-30
conceptual ideaHow to parse strings into columns  from a list of offsets (columns widths) and column names.  The rows of text are limited to a hundred or so.  The source string length is <1000 characters,   there are about 40 columns of vary widths.
EE-Excel-parse.xls
0
Comment
Question by:AndyPandy
5 Comments
 
LVL 39

Assisted Solution

by:nutsch
nutsch earned 200 total points
Comment Utility
On sheet 3, first row, formula starting in A1, copy across

=INDEX(Sheet2!$B$1:$B$40,COLUMN()+1)

On sheet3, second row, formula starting in A2, copy across and down:
=MID(INDEX(Sheet1!$A:$A,ROW()-1),INDEX(Sheet2!$A:$A,MATCH(A$1,Sheet2!$B:$B,0)),INDEX(Sheet2!$A:$A,1+MATCH(A$1,Sheet2!$B:$B,0))-INDEX(Sheet2!$A:$A,MATCH(A$1,Sheet2!$B:$B,0)))

Thomas
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 50 total points
Comment Utility
I came up with this while Thomas was posting.  Not the most elegant thing, but it does appear to preempt errors if the source strings are not long enough.

The operative formula goes in Sheet3!A2, and is copied across and down:

=MID(Sheet1!$A2,INDEX(Sheet2!$A:$A,MATCH(A$1,Sheet2!$B:$B,0),1),MAX(0,IFERROR(INDEX(Sheet2!$A:$A,MATCH(B$1,Sheet2!$B:$B,0),1),LEN(Sheet1!$A2)+1)-INDEX(Sheet2!$A:$A,MATCH(A$1,Sheet2!$B:$B,0),1)))

Q-28014774.xlsx
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 250 total points
Comment Utility
This formula should also work for Sheet3 A2 copied across and down

=MID(LEFT(Sheet1!$A2,MOD(INDEX(Sheet2!$A:$A,MATCH(A$1,Sheet2!$B:$B,0)+1)-1,1000)),SUMIF(Sheet2!$B:$B,A$1,Sheet2!$A:$A),1000)

regards, barry
0
 

Author Closing Comment

by:AndyPandy
Comment Utility
Thanks, you guys are genius'sssss
Thomas, nice but leaves #value when string too short.
Matt,  #Name?,  perhaps my Excel 2003 doesn't support your solution?
Barry, Nice short and sweet and no error.  Still trying to figure out how it does this.
Thanks guys!
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
AndyPandy,

Glad to help, and not surprised that once again barry wins the formula derby :)

One of the functions I used, IFERROR, debuted in Excel 2007, so yes, in Excel 2003 and earlier you will get a #NAME error if you use it.

Patrick
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

743 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

15 Experts available now in Live!

Get 1:1 Help Now