I have some data in A1:A50 and I want to combine 4 cells data by certain sum condition? what will be the possible code. e.g

1,2,3,4,5,6,7,8,9 ......

and I want to combine those 4 which give a sum of 8, then result shoud be 1,2,2,3.
Can any body give some code.