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
| Option Explicit
Global Wkbook As Workbook
Global MyMainSheet As Worksheet
Sub Ajoutvaleurs()
Dim MyTabRNG As Variant
Dim MyTabCons() As String
Dim MyTabVoy() As String
Set Wkbook = ActiveWorkbook
Set MyMainSheet = Wkbook.Worksheets("Sheet1")
MyTabRNG = MyMainSheet.Range(Cells(3, 2), Cells(3, 2).End(xlDown))
Dim i, j As Integer
Dim cmptCons, cmptVoy As Integer
MyTabRNG = MyMainSheet.Range(Cells(3, 2), Cells(3, 2).End(xlDown))
For i = 1 To UBound(MyTabRNG, 1)
For j = 1 To 1
'MsgBox MyTabRNG(i, j)
If Not EstVoyelle(MyTabRNG(i, j)) Then
cmptCons = cmptCons + 1
ReDim Preserve MyTabCons(1 To 1, 1 To cmptCons)
MyTabCons(1, cmptCons) = MyTabRNG(i, j)
Else
cmptVoy = cmptVoy + 1
ReDim Preserve MyTabVoy(1 To 1, 1 To cmptVoy)
MyTabVoy(1, cmptVoy) = MyTabRNG(i, j)
End If
Next j
Next i
MyMainSheet.Range(Cells(3, 4), Cells(cmptCons + 2, 4)) = Application.WorksheetFunction.Transpose(MyTabCons)
MyMainSheet.Range(Cells(3, 5), Cells(cmptVoy + 2, 5)) = Application.WorksheetFunction.Transpose(MyTabVoy)
End Sub
Public Function EstVoyelle(ByVal motTest As String) As Boolean
Dim motConsonne As String
Dim motVoyelle As String
Dim Voyelles As Variant
'Dim Consonne As Variant
Dim i
Voyelles = Array("a", "e", "i", "o", "u")
For i = LBound(Voyelles) To UBound(Voyelles)
If Left(Trim(motTest), 1) = Voyelles(i) Or Left(Trim(motTest), 1) = UCase(Voyelles(i)) Then
EstVoyelle = True
Exit For
End If
Next i
End Function |
Partager