This question already has an answer here:
I am a Filipino living in Dubai and I have a two year visa for the UK. I need to travel to Spain, can I do this using my UK visa ?
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
UK is not part ot the Schengen area so the UK visa doesn't allow you to visit Spain. You will need a Schengen visa.
6 months ago