Macpoy
XLDnaute Impliqué
bonsoir le forum,
toujours dans le but d'optimiser mon classeur de comptabilité,
j'ai une macro (qui fonctionne bien) qui, avant de reporter des données, me fait une mise en page avant impression. cette macro est faite avec des If en "cascade".
je me demandais, après avoir vu quelques select case sur cet excellent site, s'il y avait un intérêt à passer des nombreux If a des select case.
pour vous apporter "un tout petit peu de grain à moudre", voici une partie de la macro pour laquelle j'hésite entre If et select case.
merci d'avance à ceux qui vont se pencher sur ce dilemme.
@plus
toujours dans le but d'optimiser mon classeur de comptabilité,
j'ai une macro (qui fonctionne bien) qui, avant de reporter des données, me fait une mise en page avant impression. cette macro est faite avec des If en "cascade".
je me demandais, après avoir vu quelques select case sur cet excellent site, s'il y avait un intérêt à passer des nombreux If a des select case.
pour vous apporter "un tout petit peu de grain à moudre", voici une partie de la macro pour laquelle j'hésite entre If et select case.
Code:
Private Sub CommandButton1_Click()
Dim i, DerLig As Integer
Dim L, A As Long
Dim Réponse As String
Dim Quest, PtFourn, Hauteurtotaleligne, Hauteur
'Fact ==> feuille facture
DerLig = Param.[B20] [COLOR=YellowGreen]' feuille Paramêtres[/COLOR]
If DerLig > 25 Then Fact.Range("A" & DerLig).Select
If DerLig < 30 Then GoTo suite
If DerLig < 45 Then
Hauteurtotaleligne = Fact.Range(Rows(18), Rows(46)).Height
If Hauteurtotaleligne < 375 Then
L = Fact.Range("B47").End(xlUp).Row
If L > 26 Then Fact.Range("A" & L).Select
If L > 37 Then
If Fact.Range("B" & L + 1).RowHeight < 12.75 Then
L = Fact.Range("B113").End(xlUp).Row + 1
GoTo suite
End If
End If
End If
Do
If Hauteurtotaleligne > 375 Or Hauteurtotaleligne < 365 Then
For A = 46 To Fact.Range("B47").End(xlUp).Row + 1 Step -1
If Fact.Range(Rows(18), Rows(46)).Height < 365 Then
Hauteur = 365 - Hauteurtotaleligne
If Fact.Range("B" & A) = "" Then Rows(A).RowHeight = Rows(A).RowHeight + Hauteur
If Fact.Range(Rows(18), Rows(46)).Height > 365 Then Exit For
End If
A = Param.[B21]
If Fact.Range("B" & A).Height = 12.75 And Fact.Range("B" & A).Value = "" Then Rows(A).RowHeight = 2
If Fact.Range(Rows(18), Rows(46)).Height < 375 Then Exit For
Param.[B21] = A - 1
Next
Hauteurtotaleligne = Fact.Range(Rows(18), Rows(46)).Height
End If
Loop While Hauteurtotaleligne > 375
L = Fact.Range("B47").End(xlUp).Row + 1
If Rows(L).RowHeight < 12.75 Then L = Fact.Range("B113").End(xlUp).Row + 1
End If
suite:
L = Fact.Range("B47").End(xlUp).Row + 1
If Fact.Range("B" & L).RowHeight < 12.75 Or DerLig > 45 Then
L = Fact.Range("B113").End(xlUp).Row + 1
Else
L = Fact.Range("B47").End(xlUp).Row + 1
End If
Param.[B20] = L + 1
merci d'avance à ceux qui vont se pencher sur ce dilemme.
@plus