code rectification needed

  • hi ,
    i have column A as
    saa-n15-7hy
    sma-n1n-8hy
    saa-n15-9hy


    i wanted all the middle part in cloumn B (excel formaula =MID(A2,5,3)) and last three parts in cloumn C (=MID(A2,9,3)).


    below code is not working for me

  • Re: code rectification needed


    Hello Libin,


    Why dont you give this code a go:



    Let me know if it works for you
    Many Thanks


    Caleeco

  • Re: code rectification needed


    Hi...


    The following code might be of use if you have a large data set as it has minimal sheet interaction..



    Having said that. you didn't mention what you wanted in Column A for your output..


    If you just want to separate it all by the hyphen.. maybe this also..

    Code
    Sheets("Sheet1").Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, Other:=True, OtherChar:="-"

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!