Hi Nancy. You’re right, US phones use area codes, either cell phones or landlines while most countries use a unique dialing format for all cell phones.
To call another UK cell while in Spain you will use +44 7 and so on (you can also use 0044 7…). To call the same UK cell while both in Spain you will use the same dialing sequence. In this case the call will be directed to the UK and then redirected back to Spain by your friend’s UK wireless carrier. This is the way international roaming works and, in this case both you and your friend will pay for their part of the international call.
I hope this helps.