Chers Ma=EEtres du MPFE, tous puissants Dieux d'Excel et Seigneurs du
VBA
Je m'incline bien bas devant votre connaissance infinie du Tableur, et
devant la charit=E9 dont vous faites preuve en aidant les profanes que
nous sommes.
Je suis un fid=E8le lecteur de ce forum depuis des ann=E9es et ai
jusqu'ici toujours trouv=E9 une r=E9ponse =E0 mes probl=E8mes en fouillant =
un
peu. C'est donc =E0 demi fou d'avoir err=E9 pendant des jours sans trouver
de solution que je vous expose directement mon probl=E8me
Sympt=F4me:
Des fichiers qui d'un seul coup passent de quelques ko =E0 plusieurs
(voir des dizaines) de Mo
Cause:
Je me suis rendu compte que c'est en ouvrant un fichier sain en m=EAme
temps qu'un fichier buggu=E9 et en l'enregistrant que celui ci acqu=E9rait
l'embonpoint. Pire:, je cr=E9=E9 un nouveau fichier xls, je l'ouvre, je
l'enregistre sans toucher =E0 rien d'autre et boum, le fichier fait
parfois 9 Mo. (J'avais eu quelques fichiers avec des TCD qui
s'empataient et avait pens=E9 =E0 ce probl=E8me en premier, mais du coup ce
n'est pas =E7a)
Solutions test=E9es:
- redimmensionner la used range en supprimant lignes/ colonnes onglet
- copier coller seulement une partie d'un tableau dans un nouveau
classeur vierge
- diverses macros slimfast trouv=E9es sur ce forum ou sur excelabo.
celles que j'arrive =E0 lancer me font perdre que quelques touts petits
ko
- pb config ou virus: Je suis sous win XP SP3 et Office 2003 SP3.
Antivirus McAfee pro et un service informatique proactif d'une grosse
bo=EEte qui ne laisse jamais passer un virus. test=E9 sur d'autres config,
rien de ce c=F4t=E9 l=E0.
Avez vous d=E9ja rencontr=E9 ce probl=E8me? Puis-je avoir votre avis =E9cla=
ir=E9
vers quel chemin me tourner pour trouver une solution?
Merci pour toute votre attention et vos réponses pertinentes. Une fois de plus vous n'avez pas failli à votre réputation, c'est impressionnant.
J'ai testé sur deux fichiers et ça marche. Je vais continuer et je vous tiens au courant si jamais j'ai d'autres problèmes
Un grand merci à tous et longue vie au MPFE!
Bon weekend, Frédéric
isabelle
oui Jacquouille, et en voici une autre sorti du grenier, de Leo Heuser
Sub DeleteUnusedCustomNumberFormats() 'Leo Heuser May 6. 2001 'Version 1.01 Dim Buffer As Object Dim Sh As Object Dim SaveFormat As Variant Dim fFormat As Variant Dim nFormat() As Variant Dim xFormat As Long Dim Counter As Long Dim Counter1 As Long Dim Counter2 As Long Dim StartRow As Long Dim EndRow As Long Dim pPresent As Boolean Dim NumberOfFormats As Long Dim Answer Dim Cell As Object Dim DataStart As Long Dim DataEnd As Long Dim AnswerText As String Dim ActWorkbookName As String Dim BufferWorkbookName As String
NumberOfFormats = 1000 StartRow = 3 ' Do not alter this value EndRow = 16384 ' For Excel 97 and 2000 set EndRow to 65536
ReDim nFormat(0 To NumberOfFormats)
AnswerText = "Do you want to delete unused custom formats " _ & "from the workbook?" AnswerText = AnswerText & Chr(10) & "To get a list of used " _ & "and unused formats only, choose No." Answer = MsgBox(AnswerText, 259) If Answer = vbCancel Then GoTo Finito
Counter = 1 Do SaveFormat = Buffer.Value DoEvents SendKeys "{TAB 3}" For Counter1 = 1 To Counter SendKeys "{DOWN}" Next Counter1 SendKeys "+{TAB}{HOME}'{HOME}+{END}" _ & "^C{TAB 4}{ENTER}" Application.Dialogs(xlDialogFormatNumber). _ Show nFormat(0) ActiveSheet.Paste Destination:=Buffer Buffer.Value = Mid(Buffer.Value, 2) nFormat(Counter) = Buffer.Value Counter = Counter + 1 Loop Until nFormat(Counter - 1) = SaveFormat
ReDim Preserve nFormat(0 To Counter - 2)
Workbooks(BufferWorkbookName).Activate
Range("A1").Value = "Custom formats" Range("B1").Value = "Formats used in workbook" Range("C1").Value = "Formats not used" Range("A1:C1").Font.Bold = True
For Counter = 0 To UBound(nFormat) Cells(StartRow, 1).Offset(Counter, 0). _ NumberFormatLocal = nFormat(Counter) Cells(StartRow, 1).Offset(Counter, 0).Value = _ nFormat(Counter) Next Counter
Counter = 0 For Each Sh In Workbooks(ActWorkbookName).Worksheets For Each Cell In Sh.UsedRange.Cells fFormat = Cell.NumberFormatLocal If Application.WorksheetFunction.CountIf _ (Range(Cells(StartRow, 2), Cells _ (EndRow, 2)), fFormat) = 0 Then Cells(StartRow, 2).Offset(Counter, 0). _ NumberFormatLocal = fFormat Cells(StartRow, 2).Offset(Counter, 0).Value _ = fFormat Counter = Counter + 1 End If Next Cell Next Sh
xFormat = Range(Cells(StartRow, 2), Cells(EndRow, 2)). _ Find("").Row - 2 Counter2 = 0 For Counter = 0 To UBound(nFormat) pPresent = False For Counter1 = 1 To xFormat If nFormat(Counter) = Cells(StartRow, 2).Offset _ (Counter1, 0).NumberFormatLocal Then pPresent = True End If Next Counter1 If pPresent = False Then Cells(StartRow, 3).Offset(Counter2, 0). _ NumberFormatLocal = nFormat(Counter) Cells(StartRow, 3).Offset(Counter2, 0).Value = _ nFormat(Counter) Counter2 = Counter2 + 1 End If Next Counter With ActiveSheet.Columns("A:C") .AutoFit .HorizontalAlignment = xlLeft End With If Answer = vbYes Then DataStart = Range(Cells(1, 3), _ Cells(EndRow, 3)).Find("").Row + 1 DataEnd = Cells(DataStart, 3).Resize(EndRow, 1). _ Find("").Row - 1 On Error Resume Next For Each Cell In Range(Cells(DataStart, 3), _ Cells(DataEnd, 3)).Cells Workbooks(ActWorkbookName).DeleteNumberFormat _ (Cell.NumberFormat) Next Cell End If Finito: Set Cell = Nothing Set Sh = Nothing Set Buffer = Nothing End Sub
isabelle
Le 2011-03-04 12:35, Jacquouille a écrit :
Bonsoir
Au moins un qui a vu clair ... -)
Outre ce que les copains ont répondu, tu fais ce test: tu ouvres une feuille blanche, tu y sélectionne une colonne ou deux, et tu les mets en format...(date ou nombre avec décimales, peu importe.) Tes cel sont toujours vides. Tu enregistres et tu pèses ton fichier.... -)) In illo tempore, le grand chef à 4 plumes avait attiré notre attention sur ces formats qui "alourdissent". Bonne cure et bonne soirée. -)
Jacquouille
" Le vin est au repas ce que le parfum est à la femme."
oui Jacquouille, et en voici une autre sorti du grenier, de Leo Heuser
Sub DeleteUnusedCustomNumberFormats()
'Leo Heuser May 6. 2001
'Version 1.01
Dim Buffer As Object
Dim Sh As Object
Dim SaveFormat As Variant
Dim fFormat As Variant
Dim nFormat() As Variant
Dim xFormat As Long
Dim Counter As Long
Dim Counter1 As Long
Dim Counter2 As Long
Dim StartRow As Long
Dim EndRow As Long
Dim pPresent As Boolean
Dim NumberOfFormats As Long
Dim Answer
Dim Cell As Object
Dim DataStart As Long
Dim DataEnd As Long
Dim AnswerText As String
Dim ActWorkbookName As String
Dim BufferWorkbookName As String
NumberOfFormats = 1000
StartRow = 3 ' Do not alter this value
EndRow = 16384 ' For Excel 97 and 2000 set EndRow to 65536
ReDim nFormat(0 To NumberOfFormats)
AnswerText = "Do you want to delete unused custom formats " _
& "from the workbook?"
AnswerText = AnswerText & Chr(10) & "To get a list of used " _
& "and unused formats only, choose No."
Answer = MsgBox(AnswerText, 259)
If Answer = vbCancel Then GoTo Finito
Counter = 1
Do
SaveFormat = Buffer.Value
DoEvents
SendKeys "{TAB 3}"
For Counter1 = 1 To Counter
SendKeys "{DOWN}"
Next Counter1
SendKeys "+{TAB}{HOME}'{HOME}+{END}" _
& "^C{TAB 4}{ENTER}"
Application.Dialogs(xlDialogFormatNumber). _
Show nFormat(0)
ActiveSheet.Paste Destination:=Buffer
Buffer.Value = Mid(Buffer.Value, 2)
nFormat(Counter) = Buffer.Value
Counter = Counter + 1
Loop Until nFormat(Counter - 1) = SaveFormat
ReDim Preserve nFormat(0 To Counter - 2)
Workbooks(BufferWorkbookName).Activate
Range("A1").Value = "Custom formats"
Range("B1").Value = "Formats used in workbook"
Range("C1").Value = "Formats not used"
Range("A1:C1").Font.Bold = True
For Counter = 0 To UBound(nFormat)
Cells(StartRow, 1).Offset(Counter, 0). _
NumberFormatLocal = nFormat(Counter)
Cells(StartRow, 1).Offset(Counter, 0).Value = _
nFormat(Counter)
Next Counter
Counter = 0
For Each Sh In Workbooks(ActWorkbookName).Worksheets
For Each Cell In Sh.UsedRange.Cells
fFormat = Cell.NumberFormatLocal
If Application.WorksheetFunction.CountIf _
(Range(Cells(StartRow, 2), Cells _
(EndRow, 2)), fFormat) = 0 Then
Cells(StartRow, 2).Offset(Counter, 0). _
NumberFormatLocal = fFormat
Cells(StartRow, 2).Offset(Counter, 0).Value _
= fFormat
Counter = Counter + 1
End If
Next Cell
Next Sh
xFormat = Range(Cells(StartRow, 2), Cells(EndRow, 2)). _
Find("").Row - 2
Counter2 = 0
For Counter = 0 To UBound(nFormat)
pPresent = False
For Counter1 = 1 To xFormat
If nFormat(Counter) = Cells(StartRow, 2).Offset _
(Counter1, 0).NumberFormatLocal Then
pPresent = True
End If
Next Counter1
If pPresent = False Then
Cells(StartRow, 3).Offset(Counter2, 0). _
NumberFormatLocal = nFormat(Counter)
Cells(StartRow, 3).Offset(Counter2, 0).Value = _
nFormat(Counter)
Counter2 = Counter2 + 1
End If
Next Counter
With ActiveSheet.Columns("A:C")
.AutoFit
.HorizontalAlignment = xlLeft
End With
If Answer = vbYes Then
DataStart = Range(Cells(1, 3), _
Cells(EndRow, 3)).Find("").Row + 1
DataEnd = Cells(DataStart, 3).Resize(EndRow, 1). _
Find("").Row - 1
On Error Resume Next
For Each Cell In Range(Cells(DataStart, 3), _
Cells(DataEnd, 3)).Cells
Workbooks(ActWorkbookName).DeleteNumberFormat _
(Cell.NumberFormat)
Next Cell
End If
Finito:
Set Cell = Nothing
Set Sh = Nothing
Set Buffer = Nothing
End Sub
isabelle
Le 2011-03-04 12:35, Jacquouille a écrit :
Bonsoir
Au moins un qui a vu clair ... -)
Outre ce que les copains ont répondu, tu fais ce test:
tu ouvres une feuille blanche, tu y sélectionne une colonne ou deux,
et tu les mets en format...(date ou nombre avec décimales, peu
importe.) Tes cel sont toujours vides.
Tu enregistres et tu pèses ton fichier.... -))
In illo tempore, le grand chef à 4 plumes avait attiré notre attention
sur ces formats qui "alourdissent".
Bonne cure et bonne soirée. -)
Jacquouille
" Le vin est au repas ce que le parfum est à la femme."
oui Jacquouille, et en voici une autre sorti du grenier, de Leo Heuser
Sub DeleteUnusedCustomNumberFormats() 'Leo Heuser May 6. 2001 'Version 1.01 Dim Buffer As Object Dim Sh As Object Dim SaveFormat As Variant Dim fFormat As Variant Dim nFormat() As Variant Dim xFormat As Long Dim Counter As Long Dim Counter1 As Long Dim Counter2 As Long Dim StartRow As Long Dim EndRow As Long Dim pPresent As Boolean Dim NumberOfFormats As Long Dim Answer Dim Cell As Object Dim DataStart As Long Dim DataEnd As Long Dim AnswerText As String Dim ActWorkbookName As String Dim BufferWorkbookName As String
NumberOfFormats = 1000 StartRow = 3 ' Do not alter this value EndRow = 16384 ' For Excel 97 and 2000 set EndRow to 65536
ReDim nFormat(0 To NumberOfFormats)
AnswerText = "Do you want to delete unused custom formats " _ & "from the workbook?" AnswerText = AnswerText & Chr(10) & "To get a list of used " _ & "and unused formats only, choose No." Answer = MsgBox(AnswerText, 259) If Answer = vbCancel Then GoTo Finito
Counter = 1 Do SaveFormat = Buffer.Value DoEvents SendKeys "{TAB 3}" For Counter1 = 1 To Counter SendKeys "{DOWN}" Next Counter1 SendKeys "+{TAB}{HOME}'{HOME}+{END}" _ & "^C{TAB 4}{ENTER}" Application.Dialogs(xlDialogFormatNumber). _ Show nFormat(0) ActiveSheet.Paste Destination:=Buffer Buffer.Value = Mid(Buffer.Value, 2) nFormat(Counter) = Buffer.Value Counter = Counter + 1 Loop Until nFormat(Counter - 1) = SaveFormat
ReDim Preserve nFormat(0 To Counter - 2)
Workbooks(BufferWorkbookName).Activate
Range("A1").Value = "Custom formats" Range("B1").Value = "Formats used in workbook" Range("C1").Value = "Formats not used" Range("A1:C1").Font.Bold = True
For Counter = 0 To UBound(nFormat) Cells(StartRow, 1).Offset(Counter, 0). _ NumberFormatLocal = nFormat(Counter) Cells(StartRow, 1).Offset(Counter, 0).Value = _ nFormat(Counter) Next Counter
Counter = 0 For Each Sh In Workbooks(ActWorkbookName).Worksheets For Each Cell In Sh.UsedRange.Cells fFormat = Cell.NumberFormatLocal If Application.WorksheetFunction.CountIf _ (Range(Cells(StartRow, 2), Cells _ (EndRow, 2)), fFormat) = 0 Then Cells(StartRow, 2).Offset(Counter, 0). _ NumberFormatLocal = fFormat Cells(StartRow, 2).Offset(Counter, 0).Value _ = fFormat Counter = Counter + 1 End If Next Cell Next Sh
xFormat = Range(Cells(StartRow, 2), Cells(EndRow, 2)). _ Find("").Row - 2 Counter2 = 0 For Counter = 0 To UBound(nFormat) pPresent = False For Counter1 = 1 To xFormat If nFormat(Counter) = Cells(StartRow, 2).Offset _ (Counter1, 0).NumberFormatLocal Then pPresent = True End If Next Counter1 If pPresent = False Then Cells(StartRow, 3).Offset(Counter2, 0). _ NumberFormatLocal = nFormat(Counter) Cells(StartRow, 3).Offset(Counter2, 0).Value = _ nFormat(Counter) Counter2 = Counter2 + 1 End If Next Counter With ActiveSheet.Columns("A:C") .AutoFit .HorizontalAlignment = xlLeft End With If Answer = vbYes Then DataStart = Range(Cells(1, 3), _ Cells(EndRow, 3)).Find("").Row + 1 DataEnd = Cells(DataStart, 3).Resize(EndRow, 1). _ Find("").Row - 1 On Error Resume Next For Each Cell In Range(Cells(DataStart, 3), _ Cells(DataEnd, 3)).Cells Workbooks(ActWorkbookName).DeleteNumberFormat _ (Cell.NumberFormat) Next Cell End If Finito: Set Cell = Nothing Set Sh = Nothing Set Buffer = Nothing End Sub
isabelle
Le 2011-03-04 12:35, Jacquouille a écrit :
Bonsoir
Au moins un qui a vu clair ... -)
Outre ce que les copains ont répondu, tu fais ce test: tu ouvres une feuille blanche, tu y sélectionne une colonne ou deux, et tu les mets en format...(date ou nombre avec décimales, peu importe.) Tes cel sont toujours vides. Tu enregistres et tu pèses ton fichier.... -)) In illo tempore, le grand chef à 4 plumes avait attiré notre attention sur ces formats qui "alourdissent". Bonne cure et bonne soirée. -)
Jacquouille
" Le vin est au repas ce que le parfum est à la femme."
isabelle
merci Frédéric, c'est toujours avec plaisir et ça fait toujours plaisir, longue vie au MPFE isabelle
Le 2011-03-04 12:49, Frédéric Girard a écrit :
Merci pour toute votre attention et vos réponses pertinentes. Une fois de plus vous n'avez pas failli à votre réputation, c'est impressionnant.
J'ai testé sur deux fichiers et ça marche. Je vais continuer et je vous tiens au courant si jamais j'ai d'autres problèmes
Un grand merci à tous et longue vie au MPFE!
Bon weekend, Frédéric
merci Frédéric, c'est toujours avec plaisir et ça fait toujours plaisir,
longue vie au MPFE
isabelle
Le 2011-03-04 12:49, Frédéric Girard a écrit :
Merci pour toute votre attention et vos réponses pertinentes. Une fois
de plus vous n'avez pas failli à votre réputation, c'est
impressionnant.
J'ai testé sur deux fichiers et ça marche. Je vais continuer et je
vous tiens au courant si jamais j'ai d'autres problèmes