Je ne peux pas te donner de cours, parce que je suis comme toi, je tatonne.Pour les selects (déjà ça) quels sont les règles à suivre (dans quel cas est il indispensable, quand ne l'est il pas?, comment compiler deux lignes du genre :
Sheets("feuil1").Select
Range("A1").Select
etc etc
Sub Macro1()
Sheets("F2").Select
Range("A1").Select
Selection.Copy
Sheets("F1").Select
ActiveSheet.Paste
Sheets("F2").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("F1").Select
Range("B2").Select
ActiveSheet.Paste
End Sub
Sub Macro1()
'Sheets("F2").Select
'Range("A1").Select
'Selection.Copy
'Sheets("F1").Select
'ActiveSheet.Paste
With Sheets("F2")
.Range("A1").Copy Destination:=Sheets("F1").Range("A1")
.Range("B2").Copy Destination:=Sheets("F1").Range("B2")
End With
'Sheets("F2").Select
'Range("B2").Select
'Application.CutCopyMode = False
'Selection.Copy
'Sheets("F1").Select
'Range("B2").Select
'ActiveSheet.Paste
End Sub
Re...Darnel à dit:Merci à vous deux
Je n'ai jamais utilisé with; mais je sens que je vais pouvoir simplifier deux trois trucs comme ça
Gorfael, je suis comme toi, les codes que j'ai eu sur le site m'ont été expliqués, mais je lutte sur deux trois trucs faits par l'enregistreur.
Enfin, en ce qui concerne l'aide vb, je ne l'ai pas sur mon post car poste pro tout verouillé de partout.
Merci et A+
Re...Darnel à dit:Re à vous :
Puisque vous me l'avez proposer, finalement, il y a des choses pour lesquelles je ne suis pas sur d'avoir le code le plus court...
Type : Sheets("Données résils").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Il me semble que comme tout est en position : True, je doit pouvoir me contenter d'un simple :Sheets("Données résils").Protect
Qu'en pensez vous?
à l'inverse, si il n'y en a qu'un en False genre :
Sheets("Données résils").Protect DrawingObjects:=True, Contents:=False, Scenarios:=True
puis je me contenter de : Sheets("Données résils").Protect, Contents:=False
?
Enfin, comment raccourcir un code comme celui ci :
Range("E3").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R2C5,Données!R2C2:R65536C80,47,FALSE)"
merci
Range("E3").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R2C5,Données!R2C2:R65536C80,47,FALSE)"
Range("E3").FormulaR1C1 = _
"=VLOOKUP(R2C5,Données!R2C2:R65536C80,47,0)"
Sub Macro3()
With Selection.Font
.Name = "Arial"
.FontStyle = "Italique"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("D21").Select
End Sub
Sub Macro3()
With Selection
.Font.FontStyle = "Italique"
.Borders(xlEdgeLeft).Weight = xlThick
.Borders(xlEdgeTop).Weight = xlThick
.Borders(xlEdgeBottom).Weight = xlThick
.Borders(xlEdgeRight).Weight = xlThick
.ColorIndex = xlAutomatic
End With
End Sub
Range("B18:D18").Select
ActiveSheet.Unprotect
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ActiveCell.FormulaR1C1 = "=Fichesynthèse!RC"
Range("B18:D18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=clauses"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("E18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ActiveCell.FormulaR1C1 = "=Fichesynthèse!RC"
Range("E18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=clauses"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("F18:H18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ActiveCell.FormulaR1C1 = "=Fichesynthèse!RC"
Range("F18:H18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=clauses"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("B18:D18").Select
ActiveSheet.Unprotect
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
End With
ActiveCell.FormulaR1C1 = "=Fichesynthèse!RC"
Range("B18:D18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=clauses"
End With
Range("E18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
End With
ActiveCell.FormulaR1C1 = "=Fichesynthèse!RC"
Range("E18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=clauses"
End With
Range("F18:H18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
End With
ActiveCell.FormulaR1C1 = "=Fichesynthèse!RC"
Range("F18:H18").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=clauses"
End With
Sheets("Business Document").Select
Range("J5").Copy
Sheets("Tarification").Select
Range("D3").Select
ActiveSheet.Paste
Selection.UnMerge
en gros, tout ce que je ne modifie pas, j'ai pas besoin de le remettre