Function colstring(colonne&)
'---àpd numéro de colonne
colstring = Split(Columns(colonne).Address(columnAbsolute:=False), ":")(1)
End Function
Sub sh05_supp_RC_vides_sommeproduct()
Dim plage1 As Range, plage2 As Range
Dim dercol&, derligne&, r2cd$, r2cf$
t0 = Timer
On Error Resume Next
dercol = Cells(1, Columns.Count).End(1).Column
col$ = colstring(dercol)
derligne = Cells(Rows.Count, 1).End(3).Row
Set plage1 = Range(Cells(derligne, 1), Cells(derligne, dercol))
Application.ScreenUpdating = False
'--- supprimer colonnes
With plage1.Offset(1, 0)
.Formula = "=1/(1/SUMPRODUCT(N(A2:A" & derligne - 1 & "<>"""")))"
.Value = .Value
Columns("A:" & col$).Sort Key1:=Range("A1"), Order1:=xlAscending, Orientation:=xlLeftToRight
.SpecialCells(xlCellTypeConstants, 16).EntireColumn.Delete
.Value = ""
End With
dercol = Cells(1, Columns.Count).End(1).Column
Set plage2 = Range(Cells(2, dercol), Cells(derligne, dercol))
r2cd = Cells(2, 1).Address(0, 0)
r2cf = Cells(2, dercol).Address(0, 0)
'--- supprimer lignes
With plage2.Offset(0, 1)
'.Formula = "=1/(1/SUMPRODUCT(N(A2:" & r2cf & "<>"""")))"
.Formula = "=1/(1/SUMPRODUCT(N(" & r2cd & ":" & r2cf & "<>"""")))"
.Value = .Value
Rows("2:" & derligne).Sort .Cells, xlAscending, Header:=xlNo, Orientation:=xlByRows 'tri vertical
.SpecialCells(xlCellTypeConstants, 16).EntireRow.Delete
.Value = ""
End With
With ActiveSheet.UsedRange: End With '---actualise les barres de défilement
MsgBox Format(Timer - t0, "0.000\sec.")
Application.ScreenUpdating = True
End Sub