I would like to know when we can use "Hereby" herein" in a formal writing! Would you give an example please.

It is better not to use such words in formal documents. It is much better to go for a "plain English" style. These days even lawyers are starting to stop using them. They are never necessary and an alternative can always be found, even if it is a bit longer. Here are some examples:

Hereby: by this Deed (or Agreement or as the case may be) In fact "hereby" sometimes does not add anything; "I hereby declare" has the same effect as "I declare".

Herein: in this Deed (etc)

Hereinbefore: above

Hereinafter: below

Hitherto: until now

Henceforth: from the date of the Deed (etc)

If you are going to use such words then you need to understand exactly what they mean and the whole of your document needs to be written in an appropriate style. Using them wrongly or in an otherwise modern style only causes amusement.
Regular Member933
Proficient Speaker: Users in this role are known to maintain an excellent grasp of the English language. You can only be promoted to this role by the Englishforums team.
© MediaCet Ltd. 2016, xC v7.3.1.14987. All content posted by our users is a contribution to the public domain, this does not include imported usenet posts.*
For web related enquires please contact us on webmaster@mediacet.com.
*Usenet post removal: Use 'X-No-Archive' or please send proof of the poster's email, we will remove immediately.
Views expressed in this community do not reflect the views of MediaCet LTD, and we are in no way liable for such content.
Offensive or malicious content will be removed immediately, please send an email to webmaster@mediacet.com