A patient may not want CPR attempted when:
There is no medical benefit expected. CPR wasn't meant for people who are terminally ill or have severe health problems. CPR is not likely to be successful for these people.
Quality of life would suffer. Sometimes CPR is only partly successful. Though the patient survives, they may suffer damage to the brain or other organs or permanently may be dependent on a machine to breathe. This can be particularly true for the elderly and very frail.
Death is expected soon. Persons with terminal illness may not want aggressive interventions but prefer a natural peaceful death.