Separating a Column of Patterned Cells

%3CLINGO-SUB%20id%3D%22lingo-sub-2261445%22%20slang%3D%22en-US%22%3ESeparating%20a%20Column%20of%20Patterned%20Cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2261445%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20working%20with%20a%20spreadsheet%20I've%20created%20from%20an%20imported%20text%20file.%26nbsp%3B%20So%20far%2C%20so%20good.%26nbsp%3B%20There%20is%20a%20column%20of%20data%2C%20however%2C%20that%20I'd%20like%20to%20separate%20into%20multiple%20columns.%26nbsp%3B%20The%20data%20is%20always%20in%20the%20form%20of%20a%20letter%20followed%20by%20one%20OR%20two%20digits%2C%20then%20another%20letter%20followed%20by%20one%20OR%20two%20digits%20(i.e.%2C%20A%23B%23%2C%20A%23B%23%23%2C%20A%23%23B%23%2C%20or%20A%23%23B%23%23).%26nbsp%3B%20The%20first%20letter%20(A)%20in%20the%20sequence%20can%20vary.%26nbsp%3B%20The%20second%20(B)%20letter%20is%20always%20the%20same.%26nbsp%3B%20Unfortunately%2C%20when%20a%20number%20is%20a%20single%20digit%2C%20the%20text%20file%20does%20not%20make%20it%20%220%23%22.%26nbsp%3B%20I%20think%20that%20would%20make%20this%20task%20easier%20as%20it%20would%20make%20all%20of%20the%20cells%20the%20same%20number%20of%20characters.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EStarting%20with%20four%20columns%20next%20to%20the%20column%20of%20such%20cells%2C%20what%20is%20the%20best%20way%20to%20take%20the%20column%20of%20cells%20and%20divide%20the%20contents%20into%20four%20neighboring%20columns%2C%20A%20%7C%20%23%23%20%7C%20B%20%7C%20%23%23%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%20for%20the%20suggestions!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECarl%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2261445%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

I am working with a spreadsheet I've created from an imported text file.  So far, so good.  There is a column of data, however, that I'd like to separate into multiple columns.  The data is always in the form of a letter followed by one OR two digits, then another letter followed by one OR two digits (i.e., A#B#, A#B##, A##B#, or A##B##).  The first letter (A) in the sequence can vary.  The second (B) letter is always the same.  Unfortunately, when a number is a single digit, the text file does not make it "0#".  I think that would make this task easier as it would make all of the cells the same number of characters.

 

Starting with four columns next to the column of such cells, what is the best way to take the column of cells and divide the contents into four neighboring columns, A | ## | B | ## ?

 

Thanks in advance for the suggestions!

 

Carl

 

3 Replies

@Carl_W 

Let's say the data are in A2 and down.

 

In B2: =LEFT(A2)

 

The following formulas are all array formulas, to be confirmed with Ctrl+Shift+Enter after each edit.

 

In C2: =--MID(A2,2,MATCH(FALSE,ISNUMBER(--MID(MID(A2,2,5),ROW($1:$5),1)),0)-1)

In D2: =MID(A2,MATCH(FALSE,ISNUMBER(--MID(MID(A2,2,5),ROW($1:$5),1)),0)+1,1)

In E2: =--MID(A2,MATCH(FALSE,ISNUMBER(--MID(MID(A2,2,5),ROW($1:$5),1)),0)+2,2)

 

S0273.png

@Carl_W 

As variant Power Query could work with split text from non-digit to digit and opposite

image.png

Generated script is

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Character Transition" = Table.SplitColumn(
        Source,
        "Text",
        Splitter.SplitTextByCharacterTransition(
            (c) => not List.Contains({"0".."9"}, c),
            {"0".."9"}),
        {"A", "Text.2", "B.1"}
    ),
    #"Split Column by Character Transition1" = Table.SplitColumn(
        #"Split Column by Character Transition",
        "Text.2",
        Splitter.SplitTextByCharacterTransition(
            {"0".."9"},
            (c) => not List.Contains({"0".."9"}, c)
        ),
        {"A.1", "B"}
    )
in
    #"Split Column by Character Transition1"

 

Thanks, guys! I ended up with the following (each formula in the neighboring column):
=LEFT(A13,1)
=IF(ISNUMBER(MID(A13,2,2)*1),MID(A13,2,2)*1,MID(A13,2,1)*1)
=IF(ISNUMBER(RIGHT(A13,3)*1),MID(A13,4,1)*1,MID(A13,3,1))
=IF(ISNUMBER(RIGHT(A13,2)*1),RIGHT(A13,2)*1,RIGHT(A13,1)*1)