Bonjour à tous,
Je fais suite à une discussion menée conjointement avec Menhir.
Le but était de parcourir un Range SpeciallCells, ici sur 1 colonne, depuis sa dernière cellule.
Celle-ci peut s'obtenir par ailleurs en considérant la chaine de caractères de son adresse.
C'est la "ruse" que j'ai adoptée.
Mais.
Ma 1ère idée était donc de combiner 2 retours de cellules spéciales.
Le résultat retourné est faux.SpecialCells(lignes vides).SpcialCells(la dernière cellule)
Ma question est de savoir pourquoi.
Merci par avance pour vos retours.
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
57
58
59
60
61
62 Sub remplit_vides() Dim lastrow As Long Dim rngspéc As Range Dim premspéc_row As Integer Dim dernspéc_row As Integer Dim i As Integer Dim lacolonne As String lacolonne = "C" Application.ScreenUpdating = False With Worksheets("LAFEUILLE") lastrow = .Cells(.Rows.Count, 2).End(xlUp).Row With .Range(lacolonne & "3:" & lacolonne & lastrow) On Error Resume Next Set rngspéc = .SpecialCells(xlCellTypeBlanks) On Error GoTo 0 If rngspéc Is Nothing Then GoTo lend_de_lasub Debug.Print rngspéc.Address premspéc_row = rngspéc.Cells(1, 1).Row Debug.Print premspéc_row 'Ne fonctionne pas!? dernspéc_row = rngspéc.SpecialCells(xlCellTypeLastCell).Row Debug.Print dernspéc_row With rngspéc dernspéc_row = Right(.Address, Len(.Address) - InStrRev(.Address, "$")) End With Debug.Print dernspéc_row End With For i = dernspéc_row To premspéc_row Step -1 If Not (Intersect(rngspéc, .Cells(i, 3)) Is Nothing) Then With .Cells(i, 3) Debug.Print .Address .Value = .Offset(1, 0).Value End With End If Next i lend_de_lasub: Set rngspéc = Nothing End With End Sub
Partager