Programmable gain instrumentation amplifier with R-2R ladder and analog multiplexer
You could instead buy an AD8231: -



Digitally/pin-programmable gain of 1, 2, 4, 8, 16, 32, 64, or 128 plus you get a spare op-amp.

Or you could use a PGA281: -



Or maybe consider using a digipot with one of these: -



Trying to control gain by adjusting the resistors where you have shown in your question is going to be problematic especially if you input signal is very small to begin with. Factors that rule this out include: -


Injection of extra noise
Injection of bias currents from analogue gates
Inaccuracies / non-linearities of analogue gates