Aide sur code fait par l'enregistreur de macro
Comme je connais pas grand chose en vba j'ai fait ce code par l'enregistreur de macro sa fait long ce que je veut faire c'est que ce code soit valable pour tout mes tableaux futur se seront les même sauf le nom de l'onglet je me suis donc dit que je pouvais éventuellement le faire en le raccourcissant comme la fonction1 mais sa plante arrivez a fonction3???
j'ai aussi lu que les .select aurait tendance a faire ramer le code puis-je les viré si oui sa plante aussi dés que je les vires????
y'a t'il de bonnes âmes pour me donner la main
Sub J1()
'
' J1 Macro("A1").Select
fonction1 = "=IF(RC[-1]=""Excellent"",""10"",IF(RC[-1]=""Très bon"",""8"",IF(RC[-1]=""Bon"",""6"",IF(RC[-1]=""En progrès"",""5"",IF(RC[-1]=""Passable"",""3"",IF(RC[-1]=""Insuffisant"",""1"",IF(RC[-1]="""","""")))))))"
fonction2 = "TableauA29[notes1]
fonction3 = "TableauA29[notes2]"
fonction4 = "TableauA29[notes3]"
fonction5 = "TableauA29[notes4]"
fonction6 = "TableauA29[notes5]"
fonction7 = "TableauA29[notes6]"
fonction8 = "TableauA29[notes7]"
fonction9 = "TableauA29[Moyenne Générales]"
fonction10 = "TableauB28[notes1]"
fonction11 = "TableauB28[notes2]"
fonction12 = "TableauB28[Moyenne Générales]"
fonction13 = "TableauA29[présences]"
fonction14 = "TableauB28[Noms Prénoms]"
Application.ScreenUpdating = False 'masque les rafraîchissements d'écran
Range("A1").Select
'ActiveCell.FormulaR1C1 = "='_Championnat J3'!RC+7"
Range("G3").Formula = Range("F3").Formula
Range("G3").Formula =fonction1
Range("G3").Select
Selection.AutoFill Destination:=Range(fonction2), Type:=xlFillDefault
Range(fonction2).Select
Range("I3").Formula = Range("H3").Formula
Range("I3").Formula =fonction1
Range("I3").Select
Selection.AutoFill Destination:=Range(fonction3), Type:=xlFillDefault
Range(fonction3).Select
Range("K3").Formula = Range("J3").Formula
Range("K3").Formula = fonction1
Range("K3").Select
Selection.AutoFill Destination:=Range(fonction4), Type:=xlFillDefault
Range(fonction4).Select
Range("M3").Formula = Range("L3").Formula
Range("M3").Formula = fonction1
Range("M3").Select
Selection.AutoFill Destination:=Range(fonction5), Type:=xlFillDefault
Range(fonction5).Select
Range("O3").Formula = Range("N3").Formula
Range("O3").Formula = fonction1
Range("O3").Select
Selection.AutoFill Destination:=Range(fonction6), Type:=xlFillDefault
Range(fonction6).Select
Range("Q3").Formula = Range("P3").Formula
Range("Q3").Formula = fonction1
Range("Q3").Select
Selection.AutoFill Destination:=Range(fonction7), Type:=xlFillDefault
Range(fonction7).Select
Range("S3").Formula = Range("R3").Formula
Range("S3").Formula = fonction1
Range("S3").Select
Selection.AutoFill Destination:=Range(fonction8), Type:=xlFillDefault
Range(fonction8).Select
Range("T3").Select
ActiveCell.FormulaR1C1 = _
"=(RC[-13]+RC[-11]+RC[-9]+RC[-7]+RC[-5]+RC[-3]+RC[-1])/7+(RC[1])"
Range("T3").Select
Selection.AutoFill Destination:=Range(fonction9), Type:=xlFillDefault
Range(fonction9).Select
Range("G72").Formula = Range("F72").Formula
Range("G72").Formula = fonction1
Range("G72").Select
Selection.AutoFill Destination:=Range(fonction10), Type:=xlFillDefault
Range(fonction10).Select
Range("I72").Formula = Range("H72").Formula
Range("I72").Formula = fonction1
Range("I72").Select
Selection.AutoFill Destination:=Range(fonction11), Type:=xlFillDefault
Range(fonction11).Select
Range("U72").Select
ActiveCell.FormulaR1C1 = _
"=(RC[-14]+RC[-12]+RC[-10]+RC[-8]+RC[-6]+RC[-2])/5+(RC[-4]/2)+(RC[2])+(RC[1])"
Range("U72").Select
Selection.AutoFill Destination:=Range(fonction12), Type:=xlFillDefault
Range(fonction12).Select
Range("U3").Select
ActiveCell.FormulaR1C1 = "=SUM(COUNTIF(choix!RC[2]:RC[210],""1"")/100)"
Range("U3").Select
Selection.AutoFill Destination:=Range(fonction13), Type:=xlFillDefault
Range(fonction13).Select
Range("V72").Select
ActiveCell.FormulaR1C1 = "=SUM(COUNTIF(choix!R[-50]C:R[-50]C[208],""1"")/100)"
Range("V72").Select
Range("V73").Select
ActiveCell.FormulaR1C1 = "=SUM(COUNTIF(choix!R[-35]C:R[-35]C[208],""1"")/100)"
Range("V73").Select
Range("V74").Select
ActiveCell.FormulaR1C1 = "=SUM(COUNTIF(choix!R[-25]C:R[-25]C[208],""1"")/100)"
Range("V74").Select
Range("V75").Select
ActiveCell.FormulaR1C1 = "=SUM(COUNTIF(choix!R[-19]C:R[-19]C[208],""1"")/100)"
Range("V75").Select
Range("V76").Select
ActiveCell.FormulaR1C1 = "=SUM(COUNTIF(choix!R[-12]C:R[-12]C[208],""1"")/100)"
Range("V76").Select
Range("A3").Select
ActiveCell.FormulaR1C1 = "=Tableau211[[#This Row],[Colonne1]]"
Range("A3").Select
Selection.AutoFill Destination:=Range("A3:A21"), Type:=xlFillDefault
Range("A3:A21").Select
ActiveWindow.SmallScroll Down:=12
Range("A22").Select
ActiveCell.FormulaR1C1 = "=choix!R[1]C"
Range("A22").Select
Selection.AutoFill Destination:=Range("A22:A36"), Type:=xlFillDefault
Range("A22:A36").Select
Range("A37").Select
ActiveCell.FormulaR1C1 = "=choix!R[2]C"
Range("A38").Select
ActiveWindow.SmallScroll Down:=13
Range("A37").Select
Selection.AutoFill Destination:=Range("A37:A46"), Type:=xlFillDefault
Range("A37:A46").Select
Range("A47").Select
ActiveCell.FormulaR1C1 = "=choix!R[3]C"
Range("A48").Select
ActiveWindow.SmallScroll Down:=7
Range("A47").Select
Selection.AutoFill Destination:=Range("A47:A52"), Type:=xlFillDefault
Range("A47:A52").Select
Range("A53").Select
ActiveCell.FormulaR1C1 = "=choix!R[4]C"
Range("A54").Select
ActiveWindow.SmallScroll Down:=11
Range("A53").Select
Selection.AutoFill Destination:=Range("A53:A59"), Type:=xlFillDefault
Range("A53:A59").Select
Range("A60").Select
ActiveCell.FormulaR1C1 = "=choix!R[5]C"
Range("A60").Select
Selection.AutoFill Destination:=Range("A60:A61"), Type:=xlFillDefault
Range("A60:A61").Select
Range("C64").Select
ActiveWindow.SmallScroll Down:=-51
Range("A72").Select
ActiveCell.FormulaR1C1 = "=choix!R[-50]C"
Range("A73").Select
ActiveCell.FormulaR1C1 = "=choix!R[-35]C"
Range("A74").Select
ActiveCell.FormulaR1C1 = "=choix!R[-25]C"
Range("A75").Select
ActiveCell.FormulaR1C1 = "=choix!R[-19]C"
Range("A76").Select
ActiveCell.FormulaR1C1 = "=choix!R[-12]C"
'ActiveWindow.SmallScroll Down:=-75
Range(fonction14).Select
Range("B61").Select
ActiveCell.SpecialCells(xlCellTypeSameValidation).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=postes"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("D61").Select
ActiveCell.SpecialCells(xlCellTypeSameValidation).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=buteur"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ActiveWindow.SmallScroll Down:=3
Range("E61").Select
ActiveCell.SpecialCells(xlCellTypeSameValidation).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=équipes"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("T72").Select
ActiveCell.SpecialCells(xlCellTypeSameValidation).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=match"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("F55").Select
ActiveWindow.SmallScroll Down:=-55
Range("F3").Select
Range("C3").Select
Range("F3").Select
ActiveCell.SpecialCells(xlCellTypeSameValidation).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=notes"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End SubBonjour
Tu as deux fonction3
fonction2 = "TableauA[notes1]"
fonction3 = "TableauA[notes2]"
fonction4 = "TableauA[notes3]"
fonction5 = "TableauA[notes4]"
fonction6 = "TableauA[notes5]"
fonction7 = "TableauA[notes6]"
fonction3 = "TableauA[notes7]"
Cordialement
FINDRH
Oups mille excuse pour le bonjour
bonjour,
je suis toujours avec ce code et j'aimerais qu'il me serve pour tout mes tableaux soit feuil1 ce tableau feuil2 j'ai le même tableau, feuil3 même tableau etc et si je comprend bien sa doit être ces lignes là:
fonction2 = "TableauA[notes1]"qui font que le code ne peut pas me servir pour mes autres tableaux et malgré mes recherches je ne trouve pas comment faire quelqu’un pour m'aider
Bonjour
Difficile de t'aider sans une partie de classeur joint....
Peux tu joindre un bout significatif de ton classeur, anonymisé pour que l'on comprenne bien ce qu tu attends au final
Cordialement
FINDRH
bonjour,
je ne peut pas envoyer de pièce jointe pour l'instant mais en revanche si sa peut aider ce que je cherche a comprendre c'est comment dissocier cette partie de code dans
fonction2 = "TableauA29[notes1]"la solution que j'ai trouver c'est de le mettre dans chaque feuille est d'aller changer le
TableauA29du coup cela m'oblige a chaque création de feuilles (elle sont toutes idem) a rentré dans le vba copier coller le code ci dessus renter dans le code, et modifier ce code ce dont j'ai besoin c'est un code qui puisse me faire mon code (mes formules) sur toute mes feuilles et futurs feuilles et la je coince
OK
essayes de reconstituer ta fonction ainsi
fonction2 = "TableauA29[notes1]
==>
vfeuil=activesheet.name
vfonc="TableauA29[" & vfeuil & "]"
Cordialement*
FINDRH