SOLVED

visual basic and "OR" command

%3CLINGO-SUB%20id%3D%22lingo-sub-280641%22%20slang%3D%22en-US%22%3Evisual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-280641%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EDear%20friends%2C%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20am%20trying%20to%20set%20up%20an%20instruction%20in%20Visual%20Basic%20to%20replace%20error%20in%20a%20text.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ESelection.Replace%20What%3A%3D%22taic%22%2C%20Replacement%3A%3D%22taichi%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHowever%20I%20would%20like%20to%20replace%20with%20the%20same%20instruction%20several%20mistakes%20like%20%22taic%22%20OR%20%22taihi%22%20OR%20%22tachi%22%20OR%20etc.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ECould%20someone%20tell%20me%20how%20to%20write%20properly%20all%20within%20this%20instruction%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThank%20you%2C%20Juan%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-280641%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-287577%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-287577%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EIt%20worked%20perfectly.%20Thank%20you%20very%20much%20and%20congratulations!!%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-285419%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-285419%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Juan%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20another%20type%20of%20spaces%20called%20non-breaking%20space%2C%20and%20you%20need%20to%20a%20special%20trick%20to%20get%20rid%20of%20it.%3C%2FP%3E%3CP%3EI%20think%20this%20space%20is%20what%20you%20have%20in%20your%20worksheet.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20represent%20this%20space%20using%20this%20function%3A%3C%2FP%3E%3CPRE%3EChr(160)%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20this%20one%20for%20the%20regular%20space%3A%3C%2FP%3E%3CPRE%3EChr(32)%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20remove%20this%20space%20in%20addition%20to%20the%20regular%20space%2C%20please%20try%20this%20code%3A%3C%2FP%3E%3CPRE%3ESub%20RemoveAllSpacesTypes()%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Columns(%22C%3AC%22).Select%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Dim%20spaces%20As%20Variant%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20spaces%20%3D%20Array(Chr(32)%2C%20Chr(160))%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20s%20In%20spaces%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3Ds%2C%20Replacement%3A%3D%22%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20s%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20note%20that%20this%20code%20will%20remove%20all%20spaces%20including%20the%20spaces%20in%20between%20words.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-285245%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-285245%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EGood%20morning%20Haytam%20and%20thank%20you%20very%20much%20as%20it%20worked%20again!%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EDo%20you%20know%20%26nbsp%3Bwhy%20when%20I%20try%20to%20delete%20in%20a%20column%20blank%20spaces%20Excel%20does%20not%20find%20any%20blank%20spaces%3F%20The%20column%20has%20text%20but%20it%20is%20under%20the%20general%20format.%26nbsp%3BEven%20if%20I%20change%20the%20format%20to%20text%20cells%2C%20it%20does%20not%20work...%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColumns(%22C%3AC%22).Select%3CBR%20%2F%3ESelection.Replace%20What%3A%3D%22%20%22%2C%20Replacement%3A%3D%22%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20very%20much%20in%20advance%2C%20Juan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284900%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284900%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20that%20possible!%3C%2FP%3E%3CP%3EBut%20you%20cannot%20record%20them%2C%20you%20have%20to%20craft%20them%20as%20follows%3A%3C%2FP%3E%3CPRE%3ESub%20TextManipulationProcess()%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3EOn%20Error%20Resume%20Next%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Dim%20filledCells%20As%20Integer%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20filledCells%20%3D%20Application.WorksheetFunction.CountA(Selection)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Dim%20cell%20As%20Range%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20cell%20In%20Selection%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20If%20Mid(cell%2C%203%2C%201)%20%3D%20%22%3A%22%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20'Do%20nothing%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ElseIf%20Mid(cell%2C%203%2C%201)%20%3D%20%22%20%22%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20cell%20%3D%20Application.WorksheetFunction.Replace(cell%2C%203%2C%201%2C%20%22%3A%22)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ElseIf%20Mid(cell%2C%203%2C%201)%20%26lt%3B%26gt%3B%20%22%20%22%20And%20Mid(cell%2C%203%2C%201)%20%26lt%3B%26gt%3B%20%22%3A%22%20And%20cell%20%26lt%3B%26gt%3B%20%22%22%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20cell%20%3D%20Application.WorksheetFunction.Replace(cell%2C%203%2C%200%2C%20%22%3A%22)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Else%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20cell%20%3D%20%22%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20End%20If%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Dim%20counter%20As%20Integer%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20counter%20%3D%20counter%20%2B%201%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20If%20counter%20%26gt%3B%3D%20filledCells%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Exit%20For%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20End%20If%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20cell%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Dim%20r%20As%20String%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20r%20%3D%20Selection.Range(%22A1%22).Address(False%2C%20False)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20If%20Range(r).Value%20%3D%20%22%22%20Then%20Exit%20Sub%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.TextToColumns%20Destination%3A%3DRange(r)%2C%20DataType%3A%3DxlDelimited%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20TextQualifier%3A%3DxlDoubleQuote%2C%20ConsecutiveDelimiter%3A%3DFalse%2C%20Tab%3A%3DTrue%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Semicolon%3A%3DFalse%2C%20Comma%3A%3DFalse%2C%20Space%3A%3DFalse%2C%20Other%3A%3DTrue%2C%20OtherChar%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%3D%22.%22%2C%20FieldInfo%3A%3DArray(Array(1%2C%202)%2C%20Array(2%2C%202)%2C%20Array(3%2C%202)%2C%20Array(4%2C%202)%2C%20Array(5%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%202)%2C%20Array(6%2C%202)%2C%20Array(7%2C%202)%2C%20Array(8%2C%202)%2C%20Array(9%2C%202))%2C%20TrailingMinusNumbers%3A%3DTrue%3CBR%20%2F%3E%3CBR%20%2F%3EOn%20Error%20GoTo%200%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20note%20that%20you%20have%20to%20select%20the%20column%20before%20you%20run%20this%20code.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284580%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284580%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20again.%20it%20works!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20would%20it%20be%20possible%20to%20run%20those%20instructions%20from%20a%20macro%20command%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284494%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284494%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20so%2C%20before%20you%20apply%20the%20Text%20to%20Column%20process%2C%20you%20have%20to%20make%20the%20data%20consistent%20somehow.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESupposing%20that%20these%20text%20times%20always%20at%20the%20beginning%20of%20the%20string%2C%20and%20the%20third%20character%20of%20the%20string%20should%20always%20be%20(%20%3A%20)%2C%20I%20would%20suggest%20this%20formula%3A%3C%2FP%3E%3CPRE%3E%3DIF(MID(A1%2C3%2C1)%3D%22%3A%22%2CA1%2C%3CBR%20%2F%3EIF(MID(A1%2C3%2C1)%3D%22%20%22%2CREPLACE(A1%2C3%2C1%2C%22%3A%22)%2C%3CBR%20%2F%3EIF(AND(MID(A1%2C3%2C1)%26lt%3B%26gt%3B%22%20%22%2CMID(A1%2C3%2C1)%26lt%3B%26gt%3B%22%3A%22%2CA1%26lt%3B%26gt%3B%22%22)%2CREPLACE(A1%2C3%2C0%2C%22%3A%22)%2C%22%22)))%3C%2FPRE%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20747px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F59368i537A8973348D6417%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Text%20Manipulation.png%22%20title%3D%22Text%20Manipulation.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20that%2C%20%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2FReplace-a-formula-with-its-result-38001951-c0e8-4fbd-9048-37ef81e2891e%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Econvert%20the%20formulas%20to%20values%3C%2FA%3E%2C%20and%20then%20apply%20the%20text%20to%20columns%20process.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284449%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284449%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Haytam%2C%20good%20morning%20and%20thank%20you%20very%20much%20for%20your%20clear%20and%20quick%20answer.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20realized%20that%20the%20problem%20comes%20from%20imported%20data.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EData%20is%20not%20always%20perfectly%20written.%20For%20instance%2C%20%2216%3A40%22%20some%20times%20comes%20as%20%2216%2040%22%20or%20%221640%22.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20when%20executing%20%22text%20to%20column%22%2C%20cells%20having%20having%20the%20%2216%3A40%22%20form%20are%20considered%20as%20a%20personalysed%20form.%20On%20the%20other%20hand%20cells%20having%20%22%3CSPAN%3E%2216%2040%22%20or%20%221640%22%20are%20considered%20as%26nbsp%3B%3C%2FSPAN%3Ea%20general%20form.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20use%20your%20proposed%20solution%20and%20convert%20everything%20into%20text%2C%20before%20changing%26nbsp%3B%2216%2040%22%20or%20%221640%22%26nbsp%3B%20into%20%22%3CSPAN%3E16%3A40%22%26nbsp%3B%3C%2FSPAN%3Eit%20would%20be%20very%20difficult%20to%20correct%20the%20wrong%20cells.%20Is%20there%20anyway%20to%20deal%26nbsp%3B%20with%20this%20problem%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20very%20much%20again%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284407%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284407%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Juan%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20tested%20this%20code%2C%20but%20ended%20up%20with%20this%20result%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20873px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F59359i96BD6CC4EEC0EF0B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Text%20to%20column%20result.png%22%20title%3D%22Text%20to%20column%20result.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20note%20that%20all%20of%20the%20times%20are%20in%20Time%20format%2C%20even%20if%20the%20AM%2FPM%20isn't%20displayed%2C%20where%20it's%20visible%20in%20the%20formula%20bar!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20the%20reason%20why%20you%20got%20some%20cells%20formatted%20in%20AM%2FPM%20is%20that%20these%20cells%20have%20a%20preset%20custom%20format%20to%20be%20formatted%20that%20way!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20keep%20all%20the%20results%20in%20Text%20format%2C%20where%20all%20cells%20are%20aligned%20to%20the%20left%20by%20default%2C%20just%20change%20the%20second%20argument%20for%20each%20Array%20function%20%3CSTRONG%3Efrom%201%20to%202%3C%2FSTRONG%3E%20as%20follows%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EBefore%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EColumns(%22B%3AB%22).Select%3CBR%20%2F%3ESelection.TextToColumns%20Destination%3A%3DRange(%22B1%22)%2C%20DataType%3A%3DxlDelimited%2C%20_%3CBR%20%2F%3ETextQualifier%3A%3DxlDoubleQuote%2C%20ConsecutiveDelimiter%3A%3DFalse%2C%20Tab%3A%3DTrue%2C%20_%3CBR%20%2F%3ESemicolon%3A%3DFalse%2C%20Comma%3A%3DFalse%2C%20Space%3A%3DFalse%2C%20Other%3A%3DTrue%2C%20OtherChar%20_%3CBR%20%2F%3E%3A%3D%22.%22%2C%20FieldInfo%3A%3DArray(Array(1%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(2%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(3%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(4%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(5%2C%20_%3CBR%20%2F%3E%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(6%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(7%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(8%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E)%2C%20Array(9%2C%20%3CSTRONG%3E1%3C%2FSTRONG%3E))%2C%20TrailingMinusNumbers%3A%3DTrue%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EAfter%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EColumns(%22B%3AB%22).Select%3CBR%20%2F%3ESelection.TextToColumns%20Destination%3A%3DRange(%22B1%22)%2C%20DataType%3A%3DxlDelimited%2C%20_%3CBR%20%2F%3ETextQualifier%3A%3DxlDoubleQuote%2C%20ConsecutiveDelimiter%3A%3DFalse%2C%20Tab%3A%3DTrue%2C%20_%3CBR%20%2F%3ESemicolon%3A%3DFalse%2C%20Comma%3A%3DFalse%2C%20Space%3A%3DFalse%2C%20Other%3A%3DTrue%2C%20OtherChar%20_%3CBR%20%2F%3E%3A%3D%22.%22%2C%20FieldInfo%3A%3DArray(Array(1%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(2%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(3%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(4%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(5%2C%20_%3CBR%20%2F%3E%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(6%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(7%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(8%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E)%2C%20Array(9%2C%20%3CSTRONG%3E2%3C%2FSTRONG%3E))%2C%20TrailingMinusNumbers%3A%3DTrue%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20you%20can%20change%20the%20format%20option%20to%20Text%20%3CSPAN%20class%3D%22short_text%22%3E%3CSPAN%3Eduring%20recording%20the%20macro%20as%20below%20screenshot%3A%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22short_text%22%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20839px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F59360iDF7ED8B57D34EF5D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Text%20to%20Column-Text%20format.png%22%20title%3D%22Text%20to%20Column-Text%20format.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22short_text%22%3E%3CSPAN%3ERegards%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-283966%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-283966%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20again%20Haytam%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20recorded%20some%20new%20commands%20within%20the%20macro%20where%20you%20have%20already%20helped%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEnclose%20please%20find%20it%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColumns(%22B%3AB%22).Select%3CBR%20%2F%3ESelection.TextToColumns%20Destination%3A%3DRange(%22B1%22)%2C%20DataType%3A%3DxlDelimited%2C%20_%3CBR%20%2F%3ETextQualifier%3A%3DxlDoubleQuote%2C%20ConsecutiveDelimiter%3A%3DFalse%2C%20Tab%3A%3DTrue%2C%20_%3CBR%20%2F%3ESemicolon%3A%3DFalse%2C%20Comma%3A%3DFalse%2C%20Space%3A%3DFalse%2C%20Other%3A%3DTrue%2C%20OtherChar%20_%3CBR%20%2F%3E%3A%3D%22.%22%2C%20FieldInfo%3A%3DArray(Array(1%2C%201)%2C%20Array(2%2C%201)%2C%20Array(3%2C%201)%2C%20Array(4%2C%201)%2C%20Array(5%2C%20_%3CBR%20%2F%3E1)%2C%20Array(6%2C%201)%2C%20Array(7%2C%201)%2C%20Array(8%2C%201)%2C%20Array(9%2C%201))%2C%20TrailingMinusNumbers%3A%3DTrue%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20is%20that%20the%20original%20text%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E10%3A40.XX.bbb.ccc%3CBR%20%2F%3E11%3A25.ddd.eee.fff%3CBR%20%2F%3E11%3A33.ggg.hhh.iii%3CBR%20%2F%3E11%3A42.jjj.kkk.lll%3CBR%20%2F%3E12%3A10.ppp.qqq%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eafter%20running%20the%20macro%2C%20sometimes%20changes%20the%20first%20text%20into%20a%20time%20form%20and%20others%20not.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20instance%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E10%3A40%3C%2FP%3E%3CP%3E11%3A25%3A00%3AAM%3C%2FP%3E%3CP%3E11%3A42%3C%2FP%3E%3CP%3E12%3A10%3A00%3APM%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20i%20would%20like%20to%20keep%20the%20text%20form.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20help%20me%20again%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-282186%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-282186%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20Haytam%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20worked%20perfectly.%20Thank%20you%20very%20much%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20love%20to%20have%20the%20time%20to%20learn%20it%20properly.%20All%20I%20can%20only%20do%20is%20to%20record%20what%20I%20usually%20repeat%20and%20try%20to%20understand%20the%20commands%20on%20Vbasic.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20to%20have%20the%20time%20one%20day%20to%20learn%20it%20properly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyway%20your%20enormous%20help%20.%20Have%20a%20nice%20week!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-282033%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-282033%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Juan%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20maybe%20a%20bit%20confusing%20at%20first%20glance%2C%20but%20it%20will%20be%20easy%20if%20you%20learned%20the%20basics%20of%20VBA.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20a%20delaration%26nbsp%3Bstatement%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3EDim%20typos1%20As%20Variant%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20this%20an%20assignment%20statement%3A%3CBR%20%2F%3E%3CSTRONG%3Etypos1%20%3D%20Array(%22pip%3F%22%2C%20%22bibi%22%2C%20%22pi%20pi%22)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20declare%20a%20variable%20such%20as%20(typos1)%2C%20you%20should%20assign%20something%20to%20this%20variable!%3C%2FP%3E%3CP%3EAnd%20this%20what%20you%20didn't%20do!%3C%2FP%3E%3CP%3EYou%20declared%20typos1%2C%20typos2%2C%20typos3%2C%20and%20typos4%2C%20but%20you%20didn't%20assign%20anything%20to%20these%20variables!%3C%2FP%3E%3CP%3EThe%20assignment%20statement%20in%20each%20part%20is%20assigned%20to%20the%20same%20undeclared%20variable%20(typos).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20you%20declared%20typos1%20(Dim%20%3CSTRONG%3Etypos1%3C%2FSTRONG%3E%20as%20Variant)%2C%20you%20should%20follow%20it%20by%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3Etypos1%3C%2FSTRONG%3E%20%3D%20Array(%22pip%C3%AD%22%2C%20%22bibi%22%2C%20%22pi%20pi%22)%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20so%20on...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20regards%20to%20the%20variable%20after%20the%20%3CSTRONG%3EFor%20Each%2C%20What%3A%3D%20%3C%2FSTRONG%3Eand%3CSTRONG%3E%20Next%3C%2FSTRONG%3E%2C%20please%20note%20that%20I%20didn't%20change%20it%20in%20each%20block%2C%20it's%20just%20%3CSTRONG%3Etypo%3C%2FSTRONG%3E%20%3CSPAN%20class%3D%22%22%3E%3CSPAN%3Eas%20the%20previous%20reply.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%3EThe%20reason%20is%20that%20each%20For...Each%20block%20is%20independent%20of%20the%20other%2C%20so%20there%20is%20no%20need%20to%20change%20the%20name%20of%20this%20variable%20because%20it's%20defined%20only%20at%20the%20block%20level.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%3EAlso%2C%20you%20need%20to%20put%20the%20variable%20that%20you've%20declared%20after%20%3CSTRONG%3E(In)%20%3C%2FSTRONG%3Ein%20the%20loop%20statement%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%3EThis%20your%20code%20before%20adjustment%3A%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%3ESub%20ReplaceTypos()%3CBR%20%2F%3E%3CBR%20%2F%3EDim%20%3CSTRONG%3Etypos1%3C%2FSTRONG%3E%20As%20Variant%3CBR%20%2F%3E%3CSTRONG%3Etypos%3C%2FSTRONG%3E%20%3D%20Array(%22pip%3F%22%2C%20%22bibi%22%2C%20%22pi%20pi%22)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20%3CSTRONG%3Etypo1%3C%2FSTRONG%3E%20In%20%3CSTRONG%3Etypos%3C%2FSTRONG%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22pipi%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20%3CSTRONG%3Etypo1%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3EDim%20%3CSTRONG%3Etypos2%3C%2FSTRONG%3E%20As%20Variant%3CBR%20%2F%3E%3CSTRONG%3Etypos%3C%2FSTRONG%3E%20%3D%20Array(%22shark%22%2C%20%22sharv%22%2C%20%22sartv%22%2C%20%22satv%22)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20%3CSTRONG%3Etypo2%3C%2FSTRONG%3E%20In%20%3CSTRONG%3Etypos%3C%2FSTRONG%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22sarv%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20%3CSTRONG%3Etypo%3C%2FSTRONG%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3EDim%20%3CSTRONG%3Etypos3%3C%2FSTRONG%3E%20As%20Variant%3CBR%20%2F%3E%3CSTRONG%3Etypos%3C%2FSTRONG%3E%20%3D%20Array(%22marsan%22%2C%20%22marchan%22%2C%20%22marshal%22%2C%20%22marshall%22%2C%20%22mashan%22%2C%20%22mershan%22)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20%3CSTRONG%3Etypo3%3C%2FSTRONG%3E%20In%20%3CSTRONG%3Etypos%3C%2FSTRONG%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22marshan%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20%3CSTRONG%3Etypo3%3C%2FSTRONG%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3EDim%20%3CSTRONG%3Etypos4%3C%2FSTRONG%3E%20As%20Variant%3CBR%20%2F%3E%3CSTRONG%3Etypos%3C%2FSTRONG%3E%20%3D%20Array(%22findu%22%2C%20%22facebook%22)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20%3CSTRONG%3Etypo4%3C%2FSTRONG%3E%20In%20%3CSTRONG%3Etypos%3C%2FSTRONG%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22fidu%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20%3CSTRONG%3Etypo4%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%3EThis%20is%20after%20the%20adjustment%3A%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E---------------------------------------------------------------------------------------------------%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20ReplaceTypos()%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20%3CSPAN%3E%3CSTRONG%3Etypos1%3C%2FSTRONG%3E%20%3C%2FSPAN%3EAs%20Variant%3CBR%20%2F%3E%3CSPAN%3E%3CSTRONG%3Etypos1%3C%2FSTRONG%3E%20%3C%2FSPAN%3E%3D%20Array(%22pip%3F%22%2C%20%22bibi%22%2C%20%22pi%20pi%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20Each%20%3CSPAN%3E%3CSTRONG%3Etypo%3C%2FSTRONG%3E%20%3C%2FSPAN%3EIn%20%3CSTRONG%3Etypos1%20%3C%2FSTRONG%3E%3CBR%20%2F%3ESelection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22pipi%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20%3CSTRONG%3Etypo%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20%3CSTRONG%3Etypos2%20%3C%2FSTRONG%3EAs%20Variant%3CBR%20%2F%3E%3CSTRONG%3Etypos2%20%3C%2FSTRONG%3E%3D%20Array(%22shark%22%2C%20%22sharv%22%2C%20%22sartv%22%2C%20%22satv%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20Each%20%3CSTRONG%3Etypo%20%3C%2FSTRONG%3EIn%20%3CSTRONG%3Etypos2%20%3C%2FSTRONG%3E%3CBR%20%2F%3ESelection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22sarv%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20%3CSTRONG%3Etypo%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3EDim%20%3CSTRONG%3Etypos3%20%3C%2FSTRONG%3EAs%20Variant%3CBR%20%2F%3E%3CSTRONG%3Etypos3%20%3C%2FSTRONG%3E%3D%20Array(%22marsan%22%2C%20%22marchan%22%2C%20%22marshal%22%2C%20%22marshall%22%2C%20%22mashan%22%2C%20%22mershan%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20Each%20%3CSTRONG%3Etypo%20%3C%2FSTRONG%3EIn%20%3CSTRONG%3Etypos3%20%3C%2FSTRONG%3E%3CBR%20%2F%3ESelection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22marshan%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20%3CSTRONG%3Etypo%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CBR%20%2F%3EDim%20%3CSTRONG%3Etypos4%20%3C%2FSTRONG%3EAs%20Variant%3CBR%20%2F%3E%3CSTRONG%3Etypos4%20%3C%2FSTRONG%3E%3D%20Array(%22findu%22%2C%20%22facebook%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20Each%20%3CSTRONG%3Etypo%20%3C%2FSTRONG%3EIn%20%3CSTRONG%3Etypos4%3C%2FSTRONG%3E%3CBR%20%2F%3ESelection.Replace%20What%3A%3D%3CSTRONG%3Etypo%3C%2FSTRONG%3E%2C%20Replacement%3A%3D%22fidu%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20%3CSTRONG%3Etypo%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3E---------------------------------------------------------------------------------------------------%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20compare%20them%2C%20and%20note%20the%20difference.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20that%20makes%20sense%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-282026%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-282026%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20Haytam%2C%3C%2FP%3E%3CP%3EUnfortunately%20what%20I%20have%20tried%20to%20develop%20myself%20did%20not%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20only%20recognizes%20the%20first%20word.%20Can%20you%20help%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20typos1%20As%20Variant%3CBR%20%2F%3Etypos%20%3D%20Array(%22pip%C3%AD%22%2C%20%22bibi%22%2C%20%22pi%20pi%22)%3CBR%20%2F%3EFor%20Each%20typo1%20In%20typos%3CBR%20%2F%3ESelection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22pipi%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20typo1%3CBR%20%2F%3EDim%20typos2%20As%20Variant%3CBR%20%2F%3Etypos%20%3D%20Array(%22shark%22%2C%20%22sharv%22%2C%20%22sartv%22%2C%20%22satv%22)%3CBR%20%2F%3EFor%20Each%20typo2%20In%20typos%3CBR%20%2F%3ESelection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22sarv%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20typo%3CBR%20%2F%3EDim%20typos3%20As%20Variant%3CBR%20%2F%3Etypos%20%3D%20Array(%22marsan%22%2C%20%22marchan%22%2C%20%22marshal%22%2C%20%22marshall%22%2C%20%22mashan%22%2C%20%22mershan%22)%3CBR%20%2F%3EFor%20Each%20typo3%20In%20typos%3CBR%20%2F%3ESelection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22marshan%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20typo3%3CBR%20%2F%3EDim%20typos4%20As%20Variant%3CBR%20%2F%3Etypos%20%3D%20Array(%22findu%22%2C%20%22facebook%22)%3CBR%20%2F%3EFor%20Each%20typo4%20In%20typos%3CBR%20%2F%3ESelection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22fidu%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20typo4%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281913%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281913%22%20slang%3D%22en-US%22%3E%3CP%3Ei%20just%20had%20to%20add%20%22next%20typo%201%2C%202%2C%20etc%22%20and%20it%20worked.%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20very%20much%20for%20your%20quick%20and%20useful%20help.%3C%2FP%3E%3CP%3EHave%20a%20nice%20weekend!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281909%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281909%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Juan%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20should%20declare%20the%20second%20group%20of%20typos%20in%20a%20different%20name%2C%20and%20both%20of%20them%20must%20be%20declared%20as%20Variant%2C%20not%20as%20String.%3C%2FP%3E%3CP%3EI've%20been%20declared%20it%20as%20String%20in%20the%20previous%20reply%20but%20I%20quickly%20updated%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3ESub%20ReplaceTypos2()%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3EDim%20typos1%20As%20Variant%3CBR%20%2F%3Etypos1%20%3D%20Array(%22shark%22%2C%20%22sharv%22%2C%20%22sartv%22%2C%20%22satv%22)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20typo%20In%20typos1%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22sarv%22%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20LookAt%3A%3DxlPart%2C%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchFormat%3A%3DFalse%2C%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20typo%3CBR%20%2F%3E%3CBR%20%2F%3EDim%20typos2%20As%20Variant%3CBR%20%2F%3Etypos2%20%3D%20Array(%22marsh%22%2C%20%22mars%22%2C%20%22marchan%22%2C%20%22marshal%22%2C%20%22marshall%22%2C%20%22mashan%22%2C%20%22mershan%22)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20typo%20In%20typos2%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22marisan%22%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20LookAt%3A%3DxlPart%2C%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchFormat%3A%3DFalse%2C%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20typo%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281899%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281899%22%20slang%3D%22en-US%22%3E%3CP%3Ehello%20again%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20have%20tried%20to%20do%20two%20one%20after%20the%20other%20but%20it%20does%20not%20work...%20can%20you%20help%20me%20again%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20types%20As%20String%3CBR%20%2F%3Etypos%20%3D%20Array(%22shark%22%2C%20%22sharv%22%2C%20%22sartv%22%2C%20%22satv%22)%3CBR%20%2F%3EFor%20Each%20typo%20In%20typos%3CBR%20%2F%3ESelection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22sarv%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20typo%3CBR%20%2F%3EDim%20types%20As%20String%3CBR%20%2F%3Etypos%20%3D%20Array(%22marsh%22%2C%20%22mars%22%2C%20%22marchan%22%2C%20%22marshal%22%2C%20%22marshall%22%2C%20%22mashan%22%2C%20%22mershan%22)%3CBR%20%2F%3EFor%20Each%20typo%20In%20typos%3CBR%20%2F%3ESelection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22marisan%22%2C%20LookAt%3A%3DxlPart%2C%20_%3CBR%20%2F%3ESearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DFalse%2C%20SearchFormat%3A%3DFalse%2C%20_%3CBR%20%2F%3EReplaceFormat%3A%3DFalse%3CBR%20%2F%3ENext%20typo%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-281005%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-281005%22%20slang%3D%22en-US%22%3EVery%20helpful.%20thank%20you%20very%20much%20for%20your%20quick%20answer!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-280688%22%20slang%3D%22en-US%22%3ERe%3A%20visual%20basic%20and%20%22OR%22%20command%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-280688%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Juan%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20suggest%20this%20code%3A%3C%2FP%3E%3CPRE%3ESub%20ReplaceTypos()%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3EDim%20typos%20As%20Variant%3CBR%20%2F%3Etypos%20%3D%20Array(%22taic%22%2C%20%22taihi%22%2C%20%22tachi%22)%3CBR%20%2F%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20Each%20typo%20In%20typos%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Selection.Replace%20What%3A%3Dtypo%2C%20Replacement%3A%3D%22taichi%22%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20LookAt%3A%3DxlPart%2C%20SearchOrder%3A%3DxlByRows%2C%20MatchCase%3A%3DTrue%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SearchFormat%3A%3DFalse%2C%20ReplaceFormat%3A%3DFalse%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20typo%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20code%20creates%20a%20list%20of%20typos%20and%20stores%20it%20in%20an%20array%20named%20(typos).%3C%2FP%3E%3CP%3EThen%20it%20will%20loop%20through%26nbsp%3Beach%20typo%20in%20typos%20array%20and%20apply%20the%20replacement%20on%20each%20one%20of%20them.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20have%20other%20typos%20just%20expand%20the%20typos%20array%20list%20in%20the%20code%20as%20the%20syntax%20below.%3C%2FP%3E%3CPRE%3Etypos%20%3D%20Array(%22typo%201%22%2C%20%22typo%202%22%2C%20...)%20%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Dear friends,

 

I am trying to set up an instruction in Visual Basic to replace error in a text.

 

Selection.Replace What:="taic", Replacement:="taichi", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

 

However I would like to replace with the same instruction several mistakes like "taic" OR "taihi" OR "tachi" OR etc.

 

Could someone tell me how to write properly all within this instruction?

 

Thank you, Juan

 

 

 

17 Replies
Highlighted
Solution

Hi Juan,

 

I suggest this code:

Sub ReplaceTypos()
 
Dim typos As Variant
typos = Array("taic", "taihi", "tachi")

    For Each typo In typos
    
        Selection.Replace What:=typo, Replacement:="taichi", _
              LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=True, _
              SearchFormat:=False, ReplaceFormat:=False
    
    Next typo

End Sub

 

This code creates a list of typos and stores it in an array named (typos).

Then it will loop through each typo in typos array and apply the replacement on each one of them.

 

If you have other typos just expand the typos array list in the code as the syntax below.

typos = Array("typo 1", "typo 2", ...) 

 

Hope that helps

Highlighted
Very helpful. thank you very much for your quick answer!
Highlighted

hello again

 

i have tried to do two one after the other but it does not work... can you help me again?

 

Dim types As String
typos = Array("shark", "sharv", "sartv", "satv")
For Each typo In typos
Selection.Replace What:=typo, Replacement:="sarv", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo
Dim types As String
typos = Array("marsh", "mars", "marchan", "marshal", "marshall", "mashan", "mershan")
For Each typo In typos
Selection.Replace What:=typo, Replacement:="marisan", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo

Highlighted

Hi Juan,

 

You should declare the second group of typos in a different name, and both of them must be declared as Variant, not as String.

I've been declared it as String in the previous reply but I quickly updated it.

 

Sub ReplaceTypos2()
 
Dim typos1 As Variant
typos1 = Array("shark", "sharv", "sartv", "satv")

    For Each typo In typos1

        Selection.Replace What:=typo, Replacement:="sarv", _
              LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
              SearchFormat:=False, ReplaceFormat:=False

    Next typo

Dim typos2 As Variant
typos2 = Array("marsh", "mars", "marchan", "marshal", "marshall", "mashan", "mershan")

    For Each typo In typos2

        Selection.Replace What:=typo, Replacement:="marisan", _
              LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
              SearchFormat:=False, ReplaceFormat:=False

    Next typo
        
End Sub

 

Hope that helps

Highlighted

i just had to add "next typo 1, 2, etc" and it worked. 

Thank you very much for your quick and useful help.

Have a nice weekend!

Highlighted

Dear Haytam,

Unfortunately what I have tried to develop myself did not work.

 

It is only recognizes the first word. Can you help?

 

Dim typos1 As Variant
typos = Array("pipí", "bibi", "pi pi")
For Each typo1 In typos
Selection.Replace What:=typo, Replacement:="pipi", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo1
Dim typos2 As Variant
typos = Array("shark", "sharv", "sartv", "satv")
For Each typo2 In typos
Selection.Replace What:=typo, Replacement:="sarv", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo
Dim typos3 As Variant
typos = Array("marsan", "marchan", "marshal", "marshall", "mashan", "mershan")
For Each typo3 In typos
Selection.Replace What:=typo, Replacement:="marshan", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo3
Dim typos4 As Variant
typos = Array("findu", "facebook")
For Each typo4 In typos
Selection.Replace What:=typo, Replacement:="fidu", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo4

Highlighted

Hi Juan,

 

This is maybe a bit confusing at first glance, but it will be easy if you learned the basics of VBA.

 

This a delaration statement:

Dim typos1 As Variant

 

And this an assignment statement:
typos1 = Array("pip?", "bibi", "pi pi")

 

If you declare a variable such as (typos1), you should assign something to this variable!

And this what you didn't do!

You declared typos1, typos2, typos3, and typos4, but you didn't assign anything to these variables!

The assignment statement in each part is assigned to the same undeclared variable (typos).

 

After you declared typos1 (Dim typos1 as Variant), you should follow it by:

typos1 = Array("pipí", "bibi", "pi pi") 

and so on...

 

With regards to the variable after the For Each, What:= and Next, please note that I didn't change it in each block, it's just typo as the previous reply.

The reason is that each For...Each block is independent of the other, so there is no need to change the name of this variable because it's defined only at the block level.

 

Also, you need to put the variable that you've declared after (In) in the loop statement

 

This your code before adjustment:

Sub ReplaceTypos()

Dim typos1 As Variant
typos = Array("pip?", "bibi", "pi pi")

    For Each typo1 In typos
        Selection.Replace What:=typo, Replacement:="pipi", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Next typo1

Dim typos2 As Variant
typos = Array("shark", "sharv", "sartv", "satv")

    For Each typo2 In typos
        Selection.Replace What:=typo, Replacement:="sarv", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Next typo
    
Dim typos3 As Variant
typos = Array("marsan", "marchan", "marshal", "marshall", "mashan", "mershan")

    For Each typo3 In typos
        Selection.Replace What:=typo, Replacement:="marshan", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Next typo3
    
Dim typos4 As Variant
typos = Array("findu", "facebook")

    For Each typo4 In typos
        Selection.Replace What:=typo, Replacement:="fidu", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Next typo4

End Sub

 

This is after the adjustment:

--------------------------------------------------------------------------------------------------- 

Sub ReplaceTypos()

 

Dim typos1 As Variant
typos1 = Array("pip?", "bibi", "pi pi")

 

For Each typo In typos1
Selection.Replace What:=typo, Replacement:="pipi", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo

 

Dim typos2 As Variant
typos2 = Array("shark", "sharv", "sartv", "satv")

 

For Each typo In typos2
Selection.Replace What:=typo, Replacement:="sarv", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo

Dim typos3 As Variant
typos3 = Array("marsan", "marchan", "marshal", "marshall", "mashan", "mershan")

 

For Each typo In typos3
Selection.Replace What:=typo, Replacement:="marshan", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo

Dim typos4 As Variant
typos4 = Array("findu", "facebook")

 

For Each typo In typos4
Selection.Replace What:=typo, Replacement:="fidu", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next typo

 

End Sub

---------------------------------------------------------------------------------------------------

 

Please compare them, and note the difference.

 

I hope that makes sense

Highlighted

Dear Haytam,

 

It worked perfectly. Thank you very much for your help.

 

I would love to have the time to learn it properly. All I can only do is to record what I usually repeat and try to understand the commands on Vbasic.

 

I hope to have the time one day to learn it properly.

 

Anyway your enormous help . Have a nice week!

Highlighted

Hello again Haytam,

 

I have recorded some new commands within the macro where you have already helped me.

 

 

Enclose please find it:

 

Columns("B:B").Select
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=".", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1)), TrailingMinusNumbers:=True

 

The problem is that the original text:

 

10:40.XX.bbb.ccc
11:25.ddd.eee.fff
11:33.ggg.hhh.iii
11:42.jjj.kkk.lll
12:10.ppp.qqq

 

after running the macro, sometimes changes the first text into a time form and others not.

 

For instance:

 

10:40

11:25:00:AM

11:42

12:10:00:PM

 

And i would like to keep the text form.

 

Can you help me again?

Highlighted

Hi Juan,

 

I've tested this code, but ended up with this result:

Text to column result.png

 

Please note that all of the times are in Time format, even if the AM/PM isn't displayed, where it's visible in the formula bar!

 

I think the reason why you got some cells formatted in AM/PM is that these cells have a preset custom format to be formatted that way!

 

To keep all the results in Text format, where all cells are aligned to the left by default, just change the second argument for each Array function from 1 to 2 as follows:

 

Before:

Columns("B:B").Select
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=".", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1)), TrailingMinusNumbers:=True

 

After:

Columns("B:B").Select
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=".", FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, _
2), Array(6, 2), Array(7, 2), Array(8, 2), Array(9, 2)), TrailingMinusNumbers:=True

 

Or you can change the format option to Text during recording the macro as below screenshot:

 

Text to Column-Text format.png

 

 

Regards

Highlighted

Hi Haytam, good morning and thank you very much for your clear and quick answer.

 

I have realized that the problem comes from imported data.

 

Data is not always perfectly written. For instance, "16:40" some times comes as "16 40" or "1640". 

 

So, when executing "text to column", cells having having the "16:40" form are considered as a personalysed form. On the other hand cells having ""16 40" or "1640" are considered as a general form. 

 

If I use your proposed solution and convert everything into text, before changing "16 40" or "1640"  into "16:40" it would be very difficult to correct the wrong cells. Is there anyway to deal  with this problem?

 

Thank you very much again

 

Highlighted

If so, before you apply the Text to Column process, you have to make the data consistent somehow.

 

Supposing that these text times always at the beginning of the string, and the third character of the string should always be ( : ), I would suggest this formula:

=IF(MID(A1,3,1)=":",A1,
IF(MID(A1,3,1)=" ",REPLACE(A1,3,1,":"),
IF(AND(MID(A1,3,1)<>" ",MID(A1,3,1)<>":",A1<>""),REPLACE(A1,3,0,":"),"")))

Text Manipulation.png

 

After that, convert the formulas to values, and then apply the text to columns process.

 

Hope that helps

Highlighted

Thank you again. it works!

 

However, would it be possible to run those instructions from a macro command?

Highlighted

Yes, that possible!

But you cannot record them, you have to craft them as follows:

Sub TextManipulationProcess()
        
On Error Resume Next
    
    Dim filledCells As Integer
    filledCells = Application.WorksheetFunction.CountA(Selection)
    
    Dim cell As Range
    For Each cell In Selection
    
        If Mid(cell, 3, 1) = ":" Then
            'Do nothing
        ElseIf Mid(cell, 3, 1) = " " Then
            cell = Application.WorksheetFunction.Replace(cell, 3, 1, ":")
        ElseIf Mid(cell, 3, 1) <> " " And Mid(cell, 3, 1) <> ":" And cell <> "" Then
            cell = Application.WorksheetFunction.Replace(cell, 3, 0, ":")
        Else
            cell = ""
        End If
        
        Dim counter As Integer
        counter = counter + 1
        
        If counter >= filledCells Then
            Exit For
        End If
    
    Next cell

    Dim r As String
    r = Selection.Range("A1").Address(False, False)
    If Range(r).Value = "" Then Exit Sub
    
    Selection.TextToColumns Destination:=Range(r), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
    Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
    :=".", FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, _
    2), Array(6, 2), Array(7, 2), Array(8, 2), Array(9, 2)), TrailingMinusNumbers:=True

On Error GoTo 0

End Sub

 

Please note that you have to select the column before you run this code.

 

Hope that helps

Highlighted

Good morning Haytam and thank you very much as it worked again!

 

Do you know  why when I try to delete in a column blank spaces Excel does not find any blank spaces? The column has text but it is under the general format. Even if I change the format to text cells, it does not work...

 

Columns("C:C").Select
Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

 

Thank you very much in advance, Juan

Highlighted

Hi Juan,

 

There is another type of spaces called non-breaking space, and you need to a special trick to get rid of it.

I think this space is what you have in your worksheet.

 

You can represent this space using this function:

Chr(160)

 

And this one for the regular space:

Chr(32)

 

To remove this space in addition to the regular space, please try this code:

Sub RemoveAllSpacesTypes()

    Columns("C:C").Select
    
    Dim spaces As Variant
    spaces = Array(Chr(32), Chr(160))
    
    For Each s In spaces
    
        Selection.Replace What:=s, Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        
    Next s

End Sub

 

Please note that this code will remove all spaces including the spaces in between words.

 

Regards

Highlighted

It worked perfectly. Thank you very much and congratulations!!