How to reduce and automate my code

A post was merged into an existing topic: Insert loop into a case_when()