What if I have the following situation? I deposit $5500 early in the tax year into a Roth IRA, but in July find that I need to withdraw $4000 for an emergency expense. Can I put that $4K back in before the end of the tax year, or am I blocked out for the year? What if I withdraw in December? Can I replenish before April, or am I locked out?
Yes, you can, but with just a few exceptions
you have 60 days to put that money back. It does not seem to matter if the 60 day period spans a calendar year (for example, if you take the money out December 15th, 2016).
Search "60 day rule" on bogelheads and
irs.gov for more specific information. What you are essentially doing is having a distribution paid directly to you, and then you have 60 days to deposit all or a portion of it back into an IRA account of your choice.