Sunteți pe pagina 1din 2

Excel Function Dictionary 1998 - 2000 Peter Noneley A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 B C D E F G

MID Page 1 of 2 H

MID
Text ABCDEDF ABCDEDF ABCDEDF ABC-100-DEF ABC-200-DEF ABC-300-DEF Item Size: Large Item Size: Medium Item Size: Small Start Position 1 2 5 100 200 300 Large Medium Small How Many Characters Mid String 3 ABC =MID(C4,D4,E4) 3 BCD =MID(C5,D5,E5) 2 ED =MID(C6,D6,E6) =MID(C8,5,3) =MID(C9,5,3) =MID(C10,5,3) =MID(C12,12,99) =MID(C13,12,99) =MID(C14,12,99)

What Does It Do ? This function picks out a piece of text from the middle of a text entry. The function needs to know at what point it should start, and how many characters to pick. If the number of characters to pick exceeds what is available, only the available characters will be picked. Syntax =MID(OriginalText,PositionToStartPicking,NumberOfCharactersToPick) Formatting No special formatting is needed. Example 1 The following table uses the =MID() function to extract a post code from a branch ID used by a company. It is assumed that all branch ID's follow the same format with the letters identifying the postal region being in the 5th and 6th positions. Branch ID DRS-CF-476 DRS-WA-842 HLT-NP-190 Postal Region CF =MID(C35,5,2) WA =MID(C36,5,2) NP =MID(C37,5,2)

Example 2 This example shows how to extract an item which is of variable length, which is inside a piece of text which has no standard format, other than the required text is always between two slash / symbols. Full Branch Code DRS/STC/872 HDRS/FC/111 S/NORTH/874 HQ/K/875 Postal Region STC FC NORTH K

Excel Function Dictionary 1998 - 2000 Peter Noneley A 50 51 52 53 54 55 56 B C D E F G SPECIAL/UK & FR/876 UK & FR =MID(C50,FIND("/",C50)+1,FIND("/",C50,FIND("/",C50)+1)-FIND("/",C50)-1) Find the first /, plus 1 for the Start of the code. Find the second /, occurring after the first / Calculate the length of the text to extract, by subtracting the position of the first / from the position of the second /

MID Page 2 of 2 H

S-ar putea să vă placă și