If you click “Number” to change it to “Percent”, and then choose 100, that will always buy the most you can afford of that resource or structure (all the percentages are based on how much you can afford, so 50% is half of what you could afford)
I guess I had seen that button in the very beginning when I was confused about what I was supposed to do and then forgot about it and ignored it afterwards.