Barcelona is a year-round destination, but we tend to advise against travel to Madrid and Seville in the height of summer. Things can get stiflingly hot, prompting most Madrileños and Sevillanos to head for the countryside and coast during August, sending the cities into a bit of a shutdown. Barcelona is a bit cooler because of the sea, but it can still be hot and busy at this time of the year.
We think spring (April through the first half of June) and autumn/fall (mid-September through early November) are great times for this trip. Temperatures historically range from 15-25°C (59-77°F), rainfall is consistently fairly low and daylight length averages around 12 hours. In Barcelona, rainfall is technically highest in May and October, but Catalonia has experienced some of its worst droughts in living memory recently. Things are getting drier, and warmer. So if it does rain on you, spare a thought for those tending vines and orchards in the hills around the city!
We love coming to Barcelona and Seville in particular in the winter months (late November through March). You can get consecutive days of blue skies, comfortable temperatures and some lovely late afternoon light at this time of the year. The cities draw breath and feel quieter, not exactly quiet but certainly calmer. As Europe's highest capital, Madrid can be cold in winter, but you can again get days of lovely blue skies here. The average temperature is historically 5-10°C (41-50°F), so wrap up warm and you'll be fine. There's always a warming café around the next corner!