Specific number of cell to fill with color based in a dynamic cell range:

Example to SUM:
If cell D10 have the value 5 SUM from A10 to A15.
If the number from cell D10 changes to 7 and SUM changes from A10 to A17.

Thanks to "Ron Coderre":
=SUM(A10:INDEX(A10:A20,D10))
But now,i was wondering... its possible to fill the cells with color?
Example:
If D10 have the value "2" then the cell A10 to A12 will be filled also with color.

I´ve tried to use the Conditional Formation with formula but i couldn't do it.
Can i use "INDEX" in the conditional formating in the section "applies to"?

If the value from the cell D10 changes the number of cells that will be filled with color will change also.

Thank you.