If you amend your formula in column Q From:

=IF(OR(P12=0,M12=0),"",P12/M12)

To:

=IF(OR(P12=0,M12=0),0,P12/M12)

And are hell bent on keeping the merged cells then:

Sub test()
Dim wsCP As Worksheet, rng As Range, rCell As Range, tmpRng As Range
Set wsCP = Sheets("Comparateur prix")
Set rng = wsCP.Range("A12:A" & wsCP.Range("A" & Rows.Count).End(xlUp).Row)
Set tmpRng = rng(1, 1)
For Each rCell In rng.Cells
With rCell
If .MergeCells Then
If Intersect(rCell, tmpRng) Is Nothing Then
.MergeArea.Offset(, 6).Resize(.MergeArea.Rows.Count, 27).Sort wsCP.Range("Q9"), xlDescending
Set tmpRng = .MergeArea
End If
End If
End With
Next
End Sub

Hope this helps