Just to add to the above:
I'm worried that anyone should suggest using The Trainline website to plan European rail travel. They can't even get things right in this country, so I certainly wouldn't trust them with continental journeys! (When I ran a rail station, I got fed up of having to explain to passengers that the tickets they'd bought from The Trainline weren't valid for travel on any trains).
The website of the Spanish train operator, RENFE, can be found here:
https://www.renfe.com/
However that site sees each day's travel as separate and will simply tell you that there's no available service if you seek an evening departure from Cadiz to Barcelona.
The best website for planning continental rail travel is that of the German rail company, Deutsche Bahn. (I'd be prepared to bet that it's the site Mushroom25 used):
https://www.bahn.com/en/view/index.shtml
As that site shows, taking the 1855 departure from Cadiz will result in you getting stuck for nearly 7 hours overnight in Madrid (eventually arriving in Barcelona at 0840).
Taking the 2040 departure from Cadiz will leave you stuck in Seville for nearly 8 hours overnight. You get to Barcelona at 1234 (after a second change in Madrid).
[Those times are based upon travel today. Enter your own travel date in the Deutsche Bahn website to see if there's any variation when you wish to travel].
Train services at other times of day typically take between 7 and 8 hours to reach Barcelona from Cadiz. Alternatively you can take a train or bus to Jerez Airport (details from the links here:
http://www.aena.es/en/jerez-airport/public-transport.html ) and then fly to Barcelona with either Ryanair or Vueling.