Expanding numbers and letters in a cell
I created a user defined function just recently that would handle most of it.
I can easily (I just did this) help break out the J1-J3,J8,J10,J12-J15
entries into groups and make it possible to get output like
121-45 J1-J3
121-45 J8
121-45 J10
121-45 J12-15
and I can see adapting that function to split the J1-J3 and J12-J15 items
into individual ones, coming up with the appropriate list. But (there's
always a but), need to know the rules about those entries. Are they always,
and I mean literally ALWAYS, a single letter followed by digits, or can they
be something else like JA1-JA14 or J9K1-J9K12? Or can we attack it by saying
that there will always be numbers at the right end, just work backwards to
the first non-digit character and assume that's the sequence begin/end
numbers and everything to the left of them is going to remain the same?
Depending on the answer to that, I think the UDF could be turned into a
usable macro - wouldn't be totally automatic because it would probably have a
hard time finding the 'source' data items, i.e. the 121-45 and
"J1-J3,J8,J10,J12-J15" entries. But probably by setting up a couple of rules
on how to use it, it could be done. And if things are always going to be one
way, such as where ever the 121-45 is at, the list will be 1 column (or set
number of columns) to the right of it, and from there, save the info, break
up the list and start placing it on the sheet either at the same place 121-45
was at or maybe just below it or whatever and then start putting it there.
But those are details, initial problem is to get format of those Jn things
established.
"tbriggs" wrote:
I have a situation where I have data in a single cell such
as:"J1-J3,J8,J10,J12-J15" I need to expand that cell into individual
cells with J1, J2, J3, J8, J10, J12, J13, J14, J15 in them.
We usually get a bill of materials in excel format that will have a
part number and then all the reference designators associated with that
part number. So the part number of all the reference designators might
be 121-45.
The Excel file would have in cell A1, "121-45" and cell B1 would have
"J1-J3,J8,J10,J12-J15".
I would like some way to convert this to:
Before
A B
1 121-45 J1-J3,J8,J10,J12-J15
After
A B
1 121-45 J1
2 121-45 J2
3 121-45 J3
4 121-45 J8
5 121-45 J10
6 121-45 J12
7 121-45 J13
8 121-45 J14
9 121-45 J15
There is a program called BOM explorer that does a function similar to
that. It is used mainly by contract manufacturers.
Any help would be appreciated.
Thanks!
tbriggs
|