code vb ajouté automatiquement non désiré

  • Initiateur de la discussion nicole
  • Date de début
N

nicole

Guest
Bonjour à tous,

je commence ma semaine avec un petit problème et espère que vous pourrez me conseiller.

voila, j'ai crée sur une feuille un bouton auquel j'ai affecté une macro. Cette macro copie des élts sur la feuille 4 de mon classeur et les colle sur la feuille 2. J'ai effectué et non écris la macro en faisant en choisissant l'option "enregistrer". Seulement j'ai du code excédentaire qui se rajoute automatiquement et fais planter le système. Comment puis-je faire pour l'effacer ?

je joins une page word contenant mon code ici car n'ai pas pu la mettre en pj

Sub BoutonSuivicompte_QuandClic()
' BoutonSuivicompte_QuandClic Macro
Sheets("Feuil4").Select

Range("A60:L65").Select
Selection.Copy
Sheets("Feuil2").Select
Range("A34").Select
ActiveSheet.Paste

code suplémentaire ajouté automatiquement
Range("F44").Select
ActiveWindow.SmallScroll Down:=-12
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.SmallScroll Down:=3
Application.Run "nouvelleficheclient2.xls!BoutonGaranties_QuandClic"
ActiveWindow.SmallScroll Down:=-30
Application.Run "nouvelleficheclient2.xls!BoutonCoface_QuandClic"
ActiveWindow.SmallScroll Down:=-18
Application.Run "nouvelleficheclient2.xls!BoutonRisque_QuandClic"
ActiveWindow.SmallScroll Down:=9
ActiveWindow.SmallScroll ToRight:=2
ActiveWindow.SmallScroll Down:=9
Range("J51").Select
ActiveWindow.SmallScroll ToRight:=-2
ActiveWindow.SmallScroll Down:=-39
ActiveWindow.SmallScroll ToRight:=2
ActiveSheet.Shapes("Button 21").Select
Selection.ShapeRange.IncrementLeft 6#
Selection.ShapeRange.IncrementTop -153.75
ActiveWindow.SmallScroll Down:=-3
ActiveSheet.Shapes("Button 4").Select
Selection.ShapeRange.IncrementLeft 3#
Selection.ShapeRange.IncrementTop 116.25
ActiveSheet.Shapes("Button 21").Select
Selection.ShapeRange.IncrementLeft -2.25
Selection.ShapeRange.IncrementTop 33.75
Range("N9").Select
ActiveSheet.Shapes("Button 3").Select
Selection.ShapeRange.ScaleWidth 0.94, msoFalse, msoScaleFromBottomRight
Range("N10").Select
ActiveSheet.Shapes("Button 16").Select
Selection.ShapeRange.ScaleWidth 0.92, msoFalse, msoScaleFromBottomRight
Range("N12").Select
ActiveSheet.Shapes("Button 16").Select
Selection.ShapeRange.ScaleWidth 1.05, msoFalse, msoScaleFromBottomRight
Selection.ShapeRange.ScaleWidth 0.96, msoFalse, msoScaleFromBottomRight
Range("N14").Select
ActiveSheet.Shapes("Button 4").Select
Selection.ShapeRange.ScaleWidth 0.95, msoFalse, msoScaleFromBottomRight
Range("N15").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.SmallScroll Down:=27
ActiveWindow.SmallScroll ToRight:=-2
Range("H42").Select
Sheets("Feuil4").Select
ActiveWindow.SmallScroll Down:=-12
Range("A32").Select
Selection.Font.Italic = False
Range("A25").Select
Selection.Font.Italic = False
Range("A41").Select
Selection.Font.Italic = False
ActiveWindow.SmallScroll Down:=9
Range("A52").Select
Selection.Font.Italic = False
ActiveWindow.SmallScroll Down:=12
Range("A60").Select
Selection.Font.Italic = False
ActiveWindow.SmallScroll Down:=-42
Range("A9").Select
Selection.Font.Italic = False
Range("G20").Select
ActiveWindow.SmallScroll Down:=-3
Range("A25").Select
ActiveWindow.SmallScroll Down:=21
Range("B33:G38").Select
Selection.Interior.ColorIndex = 2
Range("H33").Select
ActiveWindow.SmallScroll Down:=9
Range("A43:G48").Select
Selection.Interior.ColorIndex = 2
ActiveWindow.SmallScroll Down:=6
Range("A54:H56").Select
Selection.Interior.ColorIndex = 2
Range("H43:H48").Select
ActiveWindow.SmallScroll Down:=-30
Range("A27:E29").Select
Selection.Interior.ColorIndex = 2
Range("F26").Select
ActiveWindow.SmallScroll Down:=12
Sheets("Feuil2").Select
ActiveWindow.SmallScroll Down:=-6
ActiveWorkbook.Save
Application.Run "nouvelleficheclient2.xls!FermerApplication"
Range("H52").Select
ActiveWindow.SmallScroll Down:=-21
Application.Run "nouvelleficheclient2.xls!BoutonSuivicompte_QuandClic"
ActiveWindow.SmallScroll Down:=-3
Application.WindowState = xlMinimized
End Sub

Merci et bon appétit à ceux qui vont partir en pause .
 
@

@+Thierry

Guest
Bonjour Nicole et Nicolas, le Forum

L'enregistreur est très interressant pour apprendre le VBA, par contre il est hyper "bavard", pire qu'une concierge, il espionne tout et reporte tout !

Quand on l'utilise, il faut se limiter à ne faire que les actions voulues, et le stopper immédiatement après.

Car Nicole, ce que je vois ici ce ne sont pas des lignes du code excédentaires qui se rajoutent automatiquement, mais simplement que tu as poursuivi ton travail sans arrêter l'enregistreur...

Si tu n'as besoin que de faire la copie des Cellules "A60:L65" de la feuille "Feuil4" vers la Feuil2/Cellule "A34" ce code devrait suffir :

Sub CopyPaste()
Worksheets("Feuil4").Range("A60:L65").Copy _
Destination:=Worksheets("Feuil2").Range("A34")
End Sub

Bon Après Midi
@+Thierry
 

Discussions similaires

Réponses
2
Affichages
952

Statistiques des forums

Discussions
312 505
Messages
2 089 070
Membres
104 016
dernier inscrit
Mokson