vba - distinguish between two different kinds of string and extract them -
I have a column in Excel with " 01/16 14:38 ATND [notes dealer / From the distributor] JR "and" 01/16 14:14 ATND [notes from company] JR2 "and" 01/16 14:14 ATND [Notes from the company] TLO items are ordered back "
As you can see after the bracket icon, there are two letters or three letters of three letters, JR, JR2 and TLO. I wrote a program that only differentiates between JR and TLO, but is used to extract the code, for example, for example JR and JR 2 counted for example. If someone can help me with this, then I appreciate it.
Sub G_ExtractCodes () Long LR = Range ("A" and Rows.Count) as Long LR. End (XLEEP). Note: Route = RR (phase "O" and "I") as the range in the form of red dim I Long Dime Note (NoteCode, "JR")> gt1 = 1 then cells (i, 20) = "jr" ALSIF inset (notecodes, "JR2") & gt; = 1 then cells (i, 20) = "jr2" ALSIF inset (notecodes, "TLO") & gt; = 1 then cells (i, 20) = "TLO" end if the next end end
If your first condition in the statement is more restrictive than theAlsefsection, then any instance of "JR2" will be caught by the Exam First ( Only gets "JR", andElseIfis not evaluated).Flip your argument, and I think it should fix it:
If InStr (NoteCode, "JR2")> = 1 then cells (i, 20 ) = "JR2" ALSIF Insert (NoteCode, "JR")> gt1 = 1 Then Cells (i, 20) = "JR" ALSIF Insert (NoteCode, "TLO") & gt; = 1 Then cells (i, 20) = "TLO" end ifAlternatively, you can parse these codes like:
String dim bracket position as a slow code value i = L for 2 to step 1 set Note code = range ("O" & I) 'Finds the position of correct bracket bracket location location = installer (notecod , ")") 'Closes Android to any character & amp; Correct square bracket codeValue = trim (including middle (notecodes, bracket location + 1), 'deletes any text that appears after code value, if any, if any instr (codeValue, "") & gt; 0 = CallWall = Left (codeValue, Instr (codeValue, "") End if the cell (i, 20) .Value = codeValue 'variable codeValue = vbNullString next
Comments
Post a Comment