besoin d'aide (rassembler 3 code vba en 1)

nordov6

XLDnaute Junior
saluts tous le monde
j'ai besoin de rassembler 3 codes vba en un seul
je veux quand je clic sur CommandButton les trois action s'affectue
code 1
Dim Cel As Range
For Each Cel In Range("A13:A46")
If Cel.Value <> "" And Cel.Value = 0 Then
Cel.EntireRow.Hidden = True
End If

code 2
DeBut = 2
For i = 2 To Range("A65535").End(xlUp).Row
If Cells(i + 1, 1) <> Cells(i, 1) Then
Application.DisplayAlerts = False
Range(Cells(DeBut, 1), Cells(i, 1)).Merge
DeBut = i + 1
End If
Next i
Application.DisplayAlerts = True

code 3
Sheets("recap").PrintOut Copies:=2
 

Speel

XLDnaute Occasionnel
Re : besoin d'aide (rassembler 3 code vba en 1)

Bonjour,
VB:
Sub test()
Dim Cel As Range
For Each Cel In Range("A13:A46")
If Cel.Value <> "" And Cel.Value = 0 Then
Cel.EntireRow.Hidden = True
End If
Next Cel

DeBut = 2
For i = 2 To Range("A65535").End(xlUp).Row
If Cells(i + 1, 1) <> Cells(i, 1) Then
Application.DisplayAlerts = False
Range(Cells(DeBut, 1), Cells(i, 1)).Merge
DeBut = i + 1
End If
Next i
Application.DisplayAlerts = True

Sheets("recap").PrintOut Copies:=2
End Sub

par curiosité , tu fais quoi avec ça ?
 

Speel

XLDnaute Occasionnel
Re : besoin d'aide (rassembler 3 code vba en 1)

bonsoir,
tu as du mettre " option explicit" ce qui très bien, conséquence ( avantage) il faut déclarer toutes les variables.
essais en mettant " Dim DeBut as long" et ' Dim i as long"
 

Discussions similaires

Réponses
11
Affichages
287

Statistiques des forums

Discussions
312 205
Messages
2 086 199
Membres
103 156
dernier inscrit
Ludo94130