Illegal range in part select

In reply to Desam:

Yes, this is what I tried before and it works. But I am thinking if there is any better solution for this so I ask it here. Thank you.