Bonjour,
Je coince sur un code de suppression de lignes, je veux supprimer les lignes vides de la colonne B.
Mais mon code plante et je ne trouve pas pourquoi.
Comme vous pouvez le voir je suis un super débutant.
Merci pour votre aide.
Sub masquagecolonnepourimprimerinfosflowsaisie()
' Variables globales
Dim totalRows As Integer
Dim totalCols As Integer
ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").Activate
' Nombre de lignes et colonnes utilisés dynamique
totalRows = ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").UsedRange.Rows.Count
totalCols = ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").UsedRange.Columns.Count
' Supprimer les lignes vides
Range("B1:B1048576").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
' MsgBox (Rows.Count)
' Largeur colonne automatique
Range("A:EK").Columns.AutoFit
Range("A:EK").Columns.AutoFit
Range("B:B").ColumnWidth = 20
Range("AB:AB").ColumnWidth = 14
Range("AK:AK").ColumnWidth = 34
Range("AP:AP").ColumnWidth = 34
Range("AR:AR").ColumnWidth = 14
Range("BH:BH").ColumnWidth = 34
Range("BR:BR").ColumnWidth = 34
Range("BX:BX").ColumnWidth = 34
Range("CE:CE").ColumnWidth = 34
Range("CH:CH").ColumnWidth = 34
Range("DO:DO").ColumnWidth = 34
Range("DP:DP").ColumnWidth = 34
Range("EE:EE").ColumnWidth = 34
' Centrage et renvoie à la ligne
Range("A2:EK2").Select
With Selection
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'Range("A2").Select
' Masquer colonne
Range("A:A,F:L,N:N,O:AA,AD:AJ,AL:AO,AQ:AQ,AS:BG,BI:BQ,BS:BW,BY:CG,CI:DN,DQ:ED,EF:EK").EntireColumn.Hidden = True
' Largeur ligne
Range("A:A").Rows.AutoFit
With Range(Cells(1, 1), Cells(1000, 141))
.Borders.LineStyle = xlContinuous
.Borders.Color = vbBlack
.Borders.Weight = xlThin
End With
' Orientation et marges
With ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR")
' orientation
.PageSetup.Orientation = xlLandscape
' marges
.PageSetup.LeftMargin = Application.InchesToPoints(0.118110236220472)
.PageSetup.RightMargin = Application.InchesToPoints(0.118110236220472)
.PageSetup.TopMargin = Application.InchesToPoints(0.236220472440945)
.PageSetup.BottomMargin = Application.InchesToPoints(0.31496062992126)
.PageSetup.HeaderMargin = Application.InchesToPoints(0.118110236220472)
.PageSetup.FooterMargin = Application.InchesToPoints(0.196850393700787)
End With
' Zoom
With ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR")
Application.ActiveWindow.Zoom = 30
End With
' tri colonne
ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").ListObjects( _
"Tableau_Lancer_la_requête_à_partir_de_PALMACEA3").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").ListObjects( _
"Tableau_Lancer_la_requête_à_partir_de_PALMACEA3").Sort.SortFields.Add Key:= _
Range("Tableau_Lancer_la_requête_à_partir_de_PALMACEA3[ARTSORT]"), SortOn:= _
xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").ListObjects( _
"Tableau_Lancer_la_requête_à_partir_de_PALMACEA3").Sort.SortFields.Add Key:= _
Range("Tableau_Lancer_la_requête_à_partir_de_PALMACEA3[ARTSPECIES]"), SortOn _
:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").ListObjects( _
"Tableau_Lancer_la_requête_à_partir_de_PALMACEA3").Sort.SortFields.Add Key:= _
Range("Tableau_Lancer_la_requête_à_partir_de_PALMACEA3[ARTVARIETY]"), SortOn _
:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").ListObjects( _
"Tableau_Lancer_la_requête_à_partir_de_PALMACEA3").Sort.SortFields.Add Key:= _
Range("Tableau_Lancer_la_requête_à_partir_de_PALMACEA3[PARDESIGNATION9]"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR").ListObjects( _
"Tableau_Lancer_la_requête_à_partir_de_PALMACEA3").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' With ActiveWorkbook.Worksheets("Calcul tarif Truf_JDR")
' .Sort.SortFields.Clear
' .Sort.SortFields.Add Key:=Range("C3:C1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
' .Sort.SortFields.Add Key:=Range("D3:D1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
' .Sort.SortFields.Add Key:=Range("E3:E1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
'.Sort.SortFields.Add Key:=Range("D18:D1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
' .Sort.SortFields.Add Key:=Range("Y3:Y1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
'.Sort.SortFields.Add Key:=Range("Y18:Y1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
'.Sort.SortFields.Add Key:=Range("AB10:AB1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
'.Sort.SortFields.Add Key:=Range("AD10:AD1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
' With .Sort
' .SetRange Range("A3:EG1000")
' .Header = xlGuess
' .MatchCase = False
' .Orientation = xlTopToBottom
' .SortMethod = xlPinYin
' .Apply
' End With
' End With
Columns("BR:BR").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Columns("BX:BX").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Columns("CE:CE").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Columns("CH:CH").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Columns("DO:DO").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Columns("DP:DP").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Columns("EE:EE").Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
Bonne fin de journée.
Pascal
Afficher la suite