EN replaces de + a noun

nouns introduced by partitive or indefinite articles     
(de, du, de l', de la, des) are replaced by EN            

EN may be translated as some, any or not any.
eg   Tu veux de la soupe?    [Do you want some soup]
       Tu en veux?                    [Do you want some]

       Il y a du vin?                   [Is there any wine]
       Il y en a?                         [Is there any]

nouns introduced by expressions of quantity like       
beaucoup de or a number are replaced by EN and     
the expression is at the end of the sentence              

eg  Il y a beaucoup de maisons. [There are a lot of houses]
      Il y en a beaucoup.              [There are a lot (of them)]

      J'ai envie de 10 crayons.     [I want 10 pencils]
      J'en ai envie 10.                    [I want 10 of them)]

expressions introduced by the preposition de with the following verbs are replaced with EN                        

s'occuper de  to deal with     parler de    to speak of
remercier de  to thank of      revenir de  to return from
venir de          to come from  rentrer de  to return from

 eg   Quand es-tu revenu de l'école?
                           [When did you return from the school]
           - J'en reviens tout juste!
                           [I've just returned from it]

        Tu veux parler de ce roman?
                           [Do you want to talk about this novel]
            - Tu veux en parler?
                           [Do you want to talk about it]

                                                                                           

Placement of EN

EN precedes the verb it refers to in indicatif as well as impératif négatif.
eg  De nouveaux films> Ne m'en parle pas!
                        [Some new films? Don't talk to me about them]
      Mais si, parlons-en.      [But yes, let's talk about them]

NOTE that en comes after the verb in affirmatif impératif.