The info you're providing is a little thin so there are more questions than answers here. As a start, a good place to look for busses/trains is on the trainline website at https://www.trainline.eu/. As mentioned above, between taxi, bus, train and plane you can get pretty much anywhere in Spain...