Erreur d'éxécution 1004
Bonjour,
J'ai un fichier avec plusieurs tableaux identiques. Ses 10 tableaux sont regroupés dans un autre fichier (BD_TOTALE) à l'aide d'un code VBA et d'un bouton mise à jour et un autre bouton RAZ.
Quand je vais dans l'onglet BD TOTALE et que je clic sur mise à jour ou RAZ j'ai un message:
Erreur d'éxécution '1004':
La méthode Delete de la classe Range a échoué.
Option Explicit
Dim wsData As Worksheet
Dim lo As ListObject
Public Sub Consolider()
Dim ws As Worksheet
Dim rStart As Range
Application.ScreenUpdating = False
Set wsData = ActiveWorkbook.Worksheets("BD_TOTALE")
Set lo = wsData.ListObjects(1)
With lo
If Not .DataBodyRange Is Nothing Then .DataBodyRange.Delete
Set rStart = .InsertRowRange.Cells(1)
End With
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> wsData.Name Then
Select Case ws.Name
Case "BD_France", "BD_Europe", "BD_Afrique", "BD_Amerique_du_nord", "BD_Amerique_Centrale", "BD_Amerique_du_sud", "BD_Asie", "BD_Océanie", "BD_non_Océaniens", "BD_Etats_non_reconnus"
ws.ListObjects(1).DataBodyRange.Copy
rStart.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Set rStart = lo.HeaderRowRange.Cells(1).Offset(lo.ListRows.Count + 1)
End Select
End If
Next ws
Set rStart = Nothing: Set lo = Nothing: Set wsData = Nothing
End Sub
Public Sub RAZ()
Dim wsData As Worksheet
Dim lo As ListObject
Application.ScreenUpdating = False
Set wsData = ActiveWorkbook.Worksheets("BD_TOTALE")
Set lo = wsData.ListObjects(1)
With lo
If Not .DataBodyRange Is Nothing Then .DataBodyRange.Delete
End With
Set lo = Nothing: Set wsData = Nothing
End SubLes erreurs se situent sur les lignes
If Not .DataBodyRange Is Nothing Then .DataBodyRange.DeleteC'est partie du code qui est en jaune après avoir cliqué sur déblocage
.DataBodyRange.DeleteJe signale quand même que le code à fonctionné pendant longtemps. Je ne pense pas avoir fais une mauvaise manip dans l'un de mas tableau, j'aimerais comprendre pour ce bug.
Lien vers le fichier
Bonjour,
Et si tu ôtais la protection de la feuille BD_TOTALE ?
Cdlt.
Eh ben si j'ôte la protection, ça fonctionne.
je ne sais pas pourquoi je l'ai mise.
Mille merci Jean-Eric