[Python] Highlighting cells that fit a given condition in excel using python

Discussão em 'Python' iniciado por Stack, Setembro 3, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to highlight the cells which meet the condition:


    compare all the values in the group with the final value (for that group) if that difference is > 3% highlight green if it's less than -3% highlight red
    ​

    I want to do it for a varying amount of groups of different sizes. Here's an example

    [​IMG].

    It's easy to do manually, but for a much larger dataset I'd like to not have to do it one by one.

    I just found out openpyxl exists, so not sure if that's even the way to go. Also, I have 0 VBA experience so I'm hoping python is the way, but open to suggestions.

    I've managed to do the math using pandas, but I can't change the cell colors that way so I'm stuck.

    Continue reading...

Compartilhe esta Página