Lights Dim on Electricity as well on Generator
Almost every time I had a service call where lights are dimming and don't seem to be related (such as they are not on the same circuit). I always found a broken neutral and I usually found it on the service drop. If you are replacing receptacles and switches because they need replacing then that's OK, but its not going to fix your problem. You need to look deeper into the wiring and start checking out neutrals and grounds and possibly where a ground is being used a neutral. This happens most frequently if the original wiring has been disturbed such as in a remodel area of the dwelling. 

This can be a long and drawn out process. That's why I would start at the service drop and the grounding electrode system. Take a good look where the service drop neutral is connected at the bracket and see if that is where the conductor has broken by wind movement and such. Then inspect the entire triplex drop to see if some insulation is nicked or broken off of the hot conductors and see if it has shorted and burnt the neutral in half. 

Good luck