Can this code be shortened using variables?

I think You get it, written for a newcommer....