Dance Party
Dance Party

Reputation: 3723

Xlsx Writer Conditional Formatting Based on Other Cell

Given this format and conditional formatting:

# Add a format. Light red fill.
format1 = workbook.add_format({'bg_color': '#FFC7CE'})
worksheet.conditional_format('B2:B14', 
{'type':'cell', 
'criteria': '<', 
'value': 1, 
'format': format1
})

I'd like to apply this criteria to cells B2:B14 if corresponding cells C2:C14 meet the criteria. For example, if cell C2 is less than 1, then apply the format to cell B2.

@jmcnamara ?

Thanks in advance!

Upvotes: 2

Views: 7213

Answers (1)

Dance Party
Dance Party

Reputation: 3723

This worked:

format1 = workbook.add_format({'bg_color': '#FFC7CE'})
worksheet.conditional_format('B2:B14', 
{'type':'formula', 
'criteria': '=$C2<10',  
'format': format1
})

Upvotes: 13

Related Questions