Urgent VBA Supprimer contenu du tableau

johmayss

XLDnaute Nouveau
Resolu: Urgent VBA Supprimer contenu du tableau

Bonjour à tous!

j'ai besoins d'une aide sur une macro.

J'ai besoin que tous le contenu du tableau de la feuille 4 soit effacé.
pour l'instant il n'y a que les 6 premières colonne qui s'efface.

En vous remerciant d'avance!

Voici le code:

Sub Recap(ByRef Feuille1, Feuille2, Feuille3, Feuille4)
Application.ScreenUpdating = False

'Exemple 1
'Feuille1 = "Nov09" 'Periode 1
'Feuille2 = "Dec09" 'Periode 2
'Feuille3 = "11-12" 'Synthese
'Feuille4 = "Nov09-Dec09"

colonneHMSM = 5

Sheets(Feuille3).Select



Cells(5, 1).Select
Lastline = Selection.End(xlDown).Row
If Lastline = 65536 Then Maligne = 6

Tableau1 = Range(Cells(1, 1), Cells(Lastline, 28))
ReDim tabSynthese(1 To Lastline, 1 To 7)

a = 1
For i = 5 To Lastline

For col = 1 To 28
If Cells(3, col) = "DV " Then 'Attention sur l'espace apres DV

If Cells(i, col) <> 0 Then
tabSynthese(a, 1) = Cells(i, 1) ' stock Produit
tabSynthese(a, 2) = Cells(i, 2) ' stock EAN Produit
tabSynthese(a, 3) = Cells(1, col) ' stock client
tabSynthese(a, 4) = Sheets(Feuille1).Cells(i, col) ' stock taux feuille 1
tabSynthese(a, 5) = Sheets(Feuille2).Cells(i, col) ' stock taux feuille 2
tabSynthese(a, 6) = Sheets(Feuille1).Cells(i, colonneHMSM) ' stock taux HM SM Feuille 1
tabSynthese(a, 7) = Sheets(Feuille1).Cells(2, col) ' stock taux PDM Client Feuille 1
a = a + 1
End If


End If
Next col

Next i


Sheets(Feuille4).Visible = True '
Sheets(Feuille4).Select

'Clear all data

Cells(5, 1).Select
Lastline = Selection.End(xlDown).Row
If Lastline = 65536 Then Maligne = 6
Lastcolonne = Selection.End(xlToRight).Column
Range(Cells(6, 1), Cells(Lastline, Lastcolonne)).Select
Selection.ClearContents

'Colle les data

For i = 1 To a - 1
Cells(5 + i, 1) = tabSynthese(i, 1) 'Colle le Produit
Cells(5 + i, 2) = Trim(tabSynthese(i, 2)) 'Colle l'EAN
Cells(5 + i, 3) = tabSynthese(i, 3) 'Colle le client
Cells(5 + i, 4) = tabSynthese(i, 4) 'Colle taux feuille 1
Cells(5 + i, 5) = tabSynthese(i, 5) 'Colle taux feuille 2

If tabSynthese(i, 6) <> "" Then
Cells(5 + i, 6) = ((tabSynthese(i, 5) - tabSynthese(i, 4)) * tabSynthese(i, 7)) / tabSynthese(i, 6) 'calcul Uplift
Else
Cells(5 + i, 6) = "% HM SM manquant"

End If

If tabSynthese(i, 6) <> "" Then
Cells(5 + i, 7) = ((tabSynthese(i, 5) - tabSynthese(i, 4)) / tabSynthese(i, 6)) 'calcul Uplift
Else
Cells(5 + i, 7) = "% HM SM manquant"
End If

Next i

Cells(1, 1).Select

End Sub
 
Dernière édition:

jp14

XLDnaute Barbatruc
Re : Urgent VBA Supprimer contenu du tableau

Bonjour

Il faut modifier le code

Code:
Lastline = Selection.End(xlDown).Row
If Lastline = 65536 Then Maligne = 6

a tester
Lastline = Sheets(Feuille3).Range("a65536").End(xlUp).Row

JP
 

Discussions similaires

Réponses
17
Affichages
760

Statistiques des forums

Discussions
311 725
Messages
2 081 948
Membres
101 850
dernier inscrit
Danigra