The distance between Madrid and Barcelona by road is approximately 620 km. The fastest way to cover it is by train. The cheapest is by bus.
By train
From the Atocha station, high-speed AVE trains (operated by Renfe AVE) depart towards Barcelona. Tickets cost €60-120, travel time is approximately 3 hours.
Tickets for trains to any destination in Spain are sold on the Renfe website.
By bus
A budget trip is available on the ALSA bus (company website alsa.com), which departs from Barajas Airport T4 or from Avenida de América bus station (la terminal de autobuses del intercambiador de Avenida de América). The cost is €9–40, and the journey takes about 8 hours.
Busbud (a booking service for train, bus, and plane tickets) offers an interface in Russian. This will ease the ticket purchasing process.
By car
In a rented car, you can cover the distance between the cities in about 6 hours, spending 49 liters of gasoline costing approximately €64.
You can compare prices from different rental companies here. I think you will find my advice on renting a car in Spain helpful.
By plane
Planes fly between Madrid and Barcelona. Look for cheap tickets on the lowcost.pro website.