Attached is an example with possible solution (as much of one as it was possible with so sparse info).  
 
As there was no explanation how values in column C will affect the result (I got only, that when the value in column C is less or equal of 5, then it doesn't affect the result), I added a dummy part into formula, which will add 1 whenever the value in column C will be >5. 
 
Essentially, the result is read from table in sheet ShopRanges.
		 
		
		
		
			
		
		
		
		
		
		
		
		
	
	 |