Average travelling time from BCN to Andorra la Vella is 3,5hrs via Autocars Nadal buses. You can also use Novatel andorrabybus and it's about the same, but for a higher price, they will take you to and from any address in Andorra. Schedules are pretty accurate unles there is a heavy snowfall in winter, when there can be delays.
Reserve a hotel in the centre of Andorra la Vella or Escaldes, from where the regular lines buses (very efficient) go to all the main centres in the country. As a tourist, you can also try a trip on the Visit Andorra buses which take you round some of the most interesting sights (more info at turisme.ad)