Try this (assuming entry into row 5):
Code:
=IF(ISERROR(MATCH(A5,July!A:A,0)),$C5,IF(ISBLANK(INDEX(July!G:G,MATCH(A5,July!A:A,0),1)),$C5,0))
MATCH(A5,July!A:A,0) gets the row number in "July" where the debtor name/ID is the same as the current row in "August" (assuming this is stored in column A).
The ISERROR checks to see if this can be found, if not the first IF statement results in the value from column C for this row being displayed.
The second IF statement comes into play if the name/ID already exists - it then uses INDEX to lookup the corresponding value in column G of "July" and where the row number is the same as the MATCH statment. If this is blank, you get the value from column C, otherwise zero.
Hope that helps!