pb taille fichier excel

isabe

XLDnaute Nouveau
bonjour,
j'ai un fichier de 20000 lignes pour 31 colonnes, pas de formules, pas de format particuliers dans mes cellules, 1 seul onglet...
basique de chez basique en somme!!!
et pourtant mon fichier fait 8Mo.
Une idée??
 

flyonets44

XLDnaute Occasionnel
Re : pb taille fichier excel

Bonjour
voici du code pour purger ton fichier
Sub DeleteUnused()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim myLastRow As Long, myLastCol As Long
Dim Wks As Worksheet,Vcount&
Dim dummyRng As Range
Vcount=1
For Each Wks In ActiveWorkbook.Worksheets
Set Wks = ActiveSheet
With Wks
myLastRow = ActiveSheet.UsedRange.Rows.Count
myLastCol = ActiveSheet.UsedRange.Columns.Count
Set dummyRng = ActiveSheet.UsedRange
On Error Resume Next
myLastRow = _
Wks.Cells.Find("*", after:=.Cells(1), _
LookIn:=xlFormulas, lookat:=xlWhole, _
searchdirection:=xlPrevious, _
searchorder:=xlByRows).Row
Debug.Print myLastRow

myLastCol = _
Wks.Cells.Find("*", after:=.Cells(1), _
LookIn:=xlFormulas, lookat:=xlWhole, _
searchdirection:=xlPrevious, _
searchorder:=xlByColumns).Column
Debug.Print myLastCol
On Error GoTo 0
If myLastRow * myLastCol = 0 Then
.Columns.Delete
Else
Wks.Range(Cells(myLastRow + 1, 1), _
.Cells(Rows.Count, 1)).EntireRow.Delete
Wks.Range(.Cells(1, myLastCol + 1), _
.Cells(1, .Columns.Count)).EntireColumn.Delete
End If
End With
If Vcount=1 exit for
Next Wks
set Wks =nothing
Application.Calculation = xlCalculationAutomatic
End Sub
Cordialement
Flyonets
 

Discussions similaires

Réponses
18
Affichages
651
Réponses
31
Affichages
1 K

Statistiques des forums

Discussions
312 330
Messages
2 087 335
Membres
103 523
dernier inscrit
mounir2025