|There's nothing wrong with the code itself - it works fine for me.|
The only thing I would change is to add Application.Volatile so that it updates automatically.
However. that has nothing to do with your #VALUE error.
Tell us more about your data, where you stored the code, how you are using it, etc.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.