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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| REM ***** BASIC *****
'range est la zone de cellules à traiter
'searchColumn l'index (dans range, à partir de 0) de la colonne à comparer
'txt la chaîne de caractères à chercher
Sub DeleteLines(range As Object, searchColumn As Integer, txt As String)
Dim rows As Object, rowIndex As Integer
rows = range.rows
For rowIndex = rows.count-1 To 0 Step -1
If range.GetCellByPosition(searchColumn,rowIndex).string = txt Then rows.RemoveByIndex(rowIndex,1)
Next rowIndex
End Sub
Sub Essai(val as string)
Dim oDoc As Object , Feuille As Object
oDoc=ThisComponent
Feuille = oDoc.getCurrentController().getActiveSheet()
range = Feuille.GetCellRangeByName("A9:K1150")
searchColumn = 0 'tester la 1ere colonne, A
txt = val
DeleteLines(range,searchColumn,txt)
End Sub
Sub ListeDpt
'
Dim Dpt (100 ) As String ' Tableau de 100 départements maximum
Dim i As Integer
Dim val as string
'
Dpt( 1)= ""
Dpt( 2)= "02"
Dpt( 3)= "04"
Dpt( 4)= "05"
Dpt( 5)= "06"
Dpt( 6)= "08"
Dpt( 7)= "09"
Dpt( 8)= 10
Dpt( 9)= 11
Dpt( 10)= 12
Dpt( 11)= 13
Dpt( 12)= 14
Dpt( 13)= 16
Dpt( 14)= 17
Dpt( 15)= 18
Dpt( 16)= 19
Dpt( 17)= 201
Dpt( 18)= 202
Dpt( 19)= 22
Dpt( 20)= 23
Dpt( 21)= 24
Dpt( 22)= 27
Dpt( 23)= 28
Dpt( 24)= 29
Dpt( 25)= 30
Dpt( 26)= 31
Dpt( 27)= 32
Dpt( 28)= 33
Dpt( 29)= 34
Dpt( 30)= 35
Dpt( 31)= 36
Dpt( 32)= 37
Dpt( 33)= 40
Dpt( 34)= 41
Dpt( 35)= 44
Dpt( 36)= 45
Dpt( 37)= 46
Dpt( 38)= 47
Dpt( 39)= 48
Dpt( 40)= 49
Dpt( 41)= 50
Dpt( 42)= 51
Dpt( 43)= 52
Dpt( 44)= 53
Dpt( 45)= 54
Dpt( 46)= 55
Dpt( 47)= 56
Dpt( 48)= 57
Dpt( 49)= 59
Dpt( 50)= 60
Dpt( 51)= 61
Dpt( 52)= 62
Dpt( 53)= 64
Dpt( 54)= 65
Dpt( 55)= 66
Dpt( 56)= 67
Dpt( 57)= 68
Dpt( 58)= 72
Dpt( 59)= 75
Dpt( 60)= 76
Dpt( 61)= 77
Dpt( 62)= 78
Dpt( 63)= 79
Dpt( 64)= 80
Dpt( 65)= 81
Dpt( 66)= 82
Dpt( 67)= 83
Dpt( 68)= 84
Dpt( 69)= 85
Dpt( 70)= 86
Dpt( 71)= 87
Dpt( 72)= 88
Dpt( 73)= 91
Dpt( 74)= 92
Dpt( 75)= 93
Dpt( 76)= 94
Dpt( 77)= 95
Dpt( 78)= 971
Dpt( 79)= 972
Dpt( 80)= 973
Dpt( 81)= 974
Dpt( 82)= 976
Dpt( 83) ="2A"
Dpt( 84) ="2B"
'
' Ecriture avec une boucle For.. To.. Next
For i = 1 To 84
val = Dpt (i )
Essai (val)
Next i
msgbox "OK"
end sub |
Partager