Hi,
I'm no expert, but if you have a UK will in which you include the Spanish property then that will is valid.
BUT, it may take a year or more to have the UK will recognised in the Spanish courts before your heirs can take possesion and of course it will be expensive.
That is why it is recommended you make a Spanish will covering your assets in Spain. Maria de Castro on this site is a lawyer and the best person to contact initially about your query.
Regards,