Bonjour

J'ai un problème de syntaxe et/ou de méthode concernant l'objet worksheet et la propriété range.
Le code suivant marche lorsque je le copie dans un nouveau fichier.
Or j'ai beau supprimer tout le reste dans mon ancien fichier et faire un copier/coller j'ai l'erreur suivante :

"La méthode Range de l'objet Worksheet a échoué"

à la ligne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
feuille11.Range(Cells(ligne11, colonne11), Cells(ligne22, colonne22)).Select
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Sub test()
 
Dim fSh2 As Worksheet
Set fSh2 = ActiveWorkbook.Sheets("Feuil1")
 
Call Quadrillage(fSh2, 4, 10, 4, 12)
 
 
End Sub
 
 
Sub Quadrillage(feuille11 As Worksheet, ligne11 As Integer, colonne11 As Integer, ligne22 As Integer, colonne22 As Integer)
 
feuille11.Range(Cells(ligne11, colonne11), Cells(ligne22, colonne22)).Select
 
'feuille.Activate
 
'Range(Cells(ligne1, colonne1), Cells(ligne2, colonne2)).Select
 
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
    .LineStyle = xlContinuous
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .Weight = xlThin
End With
 
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
 
 
End Sub
Je sais qu'il ne faut pas trop utiliser la méthode 'selection'.
J'envisage d'utilser par la suite qqc du style :
Merci d'avance !