A method for preparation of ranolazine comprises a step of condensing N (2 6 dimethylphenyl) 1 piperazinyl acetamide with a compound of formula (I) to obtain ranolazine in which X is chlorine or bromine. Ranolazine is prepared by condensing ring opening halide which replaces epoxide in this method.