A few questions first:
Where are you flying from? You will need time to get over jetlag when you arrive in Barcelona so I would add at least an extra night in Barcelona.
What are your interests? Do you like art museums? If you like art, I would add an extra night to Madrid which has some outstanding art museums. History? Culture? Do you like to have free time to explore neighborhoods? Do you want to check sites off a list or get to know a place a little bit better?
I haven't been to Valencia so can't comment on your stop there. Haven't been to Ronda either but I would not give up Cordoba for Ronda.
Cordoba has the magnificent Mezquita along with other important sites such as the Alcazar and its beautiful gardens, the Roman Bridge, Palacio de Viana with its lovely 12 patios. The Juderia is fun to explore with its narrow lanes, white-washed buildings, patios and flower pots.
Toledo is an ancient city located on a hill and filled with Arab, Jewish and Christian monuments and history. You could visit as a day trip from Madrid, or spend a night or two.
A possible itinerary could be:
Barcelona - 5 nights (there is so much to see in Barcelona and you need time to get over jetlag)
Granada - 2 or 3 nights (fly from Barcelona to Granada)
Seville - 4 nights (Seville is beautiful with so much to see and do here; it's larger than Cordoba and Granada and deserves at least 4 nights) Train or ALSA bus to Seville
Cordoba - 2 nights (an important historical and cultural city) Train to Cordoba.
Madrid - 4 nights to include a daytrip to Toledo although I think spending a night or 2 in Toledo is preferable. Train to Madrid.
This is a total of 18 nights. If your heart is set on Ronda, you could spend 1 night in Ronda and decrease Granada to 2 nights. This is your trip; if you prefer to visit Valencia, you should do that. You don't have time for everything. But I can't imagine being in Andalusia and not seeing the Mezquita in Cordoba.
I assume you will do open-jaw or multi-city: fly into Barcelona and home from Madrid.