Hi,
I'll try again.... If R1 is 1k and R2 is 3.5k and the voltage at the top of the divider as well as VRef is 5V then you'll get an ideal ADC reading of 796, which will be your highest reading. So far so good.

Now, doing the dummy=1000*advalue isn't a problem, the problem comes when you do Resistor = div32 10 becasue the result of that calculation WILL overflow the WORD sized variable resistor (79600) so the concept is flawed.

Apart from that you don't have enough resolution to "get to" the last digit. Your resistive range is 3450 ohms, the voltage at the ADC input will range from 0.238V to 3.889V giving you ADC readings ranging from 48 to 796.
So all you have is 796-48=748 "steps" for your total range of 3450 ohms, a resolution of roughly 3450/748 = 4 ohm which is why you get 1036 instead of 1030 and 54 instead of 50.

You can use oversampling to increase the resolution of the measurement.

/Henrik.