Reduire taille fichier

Bonjour à toutes et tous,

J'ai récupéré (merci à son auteur) et utilisé le code ci dessous copié, certes il fonctionne très bien mais j'ai remarqué le problème suivant :

La macro efface toutes les colonnes à partir de IV (L1C256) certainement ce qui était la limite du nombre de colonne maxi avant excel 2007.

Malgré mes essais je n'arrive pas à adapter ce code pour tenir compte que mon fichier utilise des colonnes au delà de IV

Auriez vous une solution ?

Merci

Cordialement

Hugues

Sub Nettoie()

Dim Sht As Worksheet, DCell As Range, Calc As Long, Rien As String, Avant As Double, plage As Range

On Error Resume Next

Calc = Application.Calculation

With Application

.Calculation = xlCalculationManual

.StatusBar = "Nettoyage en cours..."

.EnableCancelKey = xlErrorHandler

.ScreenUpdating = True

End With

For Each Sht In Worksheets

Avant = Sht.UsedRange.Cells.Count

Application.StatusBar = Sht.Name & "-" & Sht.UsedRange.Address

If Sht.UsedRange.Address <> "$A$1" Or Not IsEmpty(Sht.[A1]) Then

Set DCell = Sht.Cells.Find("*", , , , xlByRows, xlPrevious)(2)

If Not DCell Is Nothing Then

Sht.Range(DCell, Sht.Cells([A:A].Count, 1)).EntireRow.Delete

Set DCell = Nothing

Set DCell = Sht.Cells.Find("*", , , , xlByColumns, xlPrevious)(, 2)

If Not DCell Is Nothing Then Sht.Range(DCell, Sht.[IV1]).EntireColumn.Delete

End If

Rien = Sht.UsedRange.Address

End If

Next Sht

Application.StatusBar = False

Application.Calculation = Calc

ActiveWorkbook.Save

End Sub

Bonjour HUGOBASS,

Essaie en remplçant cette ligne :

If Not DCell Is Nothing Then Sht.Range(DCell, Sht.[IV1]).EntireColumn.Delete

par celle-ci :

If Not DCell Is Nothing Then Sht.Range(DCell, Sht.Cells(1, Columns.Count)).EntireColumn.Delete

Ça marchera quelque soit ta version d'Excel.

Bonjour vba-new

Merci ta solution fonctionne parfaitement

cordialement

Hugues

Rechercher des sujets similaires à "reduire taille fichier"