Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 14/12/2011, 17h26   #1
Invité de passage
 
Homme
Étudiant
Inscription : décembre 2011
Messages : 14
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Rwanda

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2011
Messages : 14
Points : 4
Points : 4
Par défaut remplacement des mots dans la meme colonne

bonjour,je voulais vous demander l'aide:
voici ma question,donc j'ai developer un userform ou je dois entrer les mots dans l'excel sheet tout en se basant de prefixe,soit les le mot qui commencent par "im' ou "imy doivent se stocker dans la même colonne.ainsi de suite,mais le problem que j'ai est que si j'entre le mot commencant par exemple par "im" et ensuite le mot comancant par "imy" le deuxieme mot,au lieu d'aller dans la ligne suivante,le mot remplace le entré precedement,si ça ne vous gene pas vous pouvez tester le fourmulaire attacher.donc le probleme que j'ai c'est le remplacement de mots dans le meme colonne au lieu de suivre dans la ligne suivante. voici me codes

Code :
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
 
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("amajyi")
 
iRow = ws.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row
 
 
 
If (Left(txtKiny.Text, 3) = "umu") Or (Left(txtKiny.Text, 3) = "umw") Or (Left(txtKiny.Text, 2) = "mu") Or (Left(txtKiny.Text, 2) = "mw") Then
  ws.Cells(iRow, 1).Value = Me.txtKiny.Value
 
End If
If (Left(txtKiny.Text, 3) = "aba") Or (Left(txtKiny.Text, 2) = "ab") Or (Left(txtKiny.Text, 2) = "ba") Then
  ws.Cells(iRow, 2).Value = Me.txtKiny.Value
End If
 
If (Left(txtKiny.Text, 3) = "imi") Or (Left(txtKiny.Text, 3) = "imy") Or (Left(txtKiny.Text, 2) = "mi") Or (Left(txtKiny.Text, 2) = "my") Then
    ws.Cells(iRow, 3).Value = Me.txtKiny.Value
End If
If (Left(txtKiny.Text, 3) = "iri") Or (Left(txtKiny.Text, 3) = "iry") Or (Left(txtKiny.Text, 2) = "ri") Or (Left(txtKiny.Text, 2) = "ry") Then
   ws.Cells(iRow, 4).Value = Me.txtKiny.Value
End If
If (Left(txtKiny.Text, 3) = "ama") Or (Left(txtKiny, 2) = "am") Or (Left(txtKiny.Text, 2) = "ma") Then
    ws.Cells(iRow, 5).Value = Me.txtKiny.Value
End If
 
If (Left(txtKiny.Text, 3) = "iki") Or (Left(txtKiny.Text, 3) = "icy") Or (Left(txtKiny.Text, 3) = "igi") Then
    ws.Cells(iRow, 6).Value = Me.txtKiny.Value
End If
If (Left(txtKiny.Text, 3) = "ibi") Or (Left(txtKiny.Text, 3) = "ibyi") Or (Left(txtKiny.Text, 2) = "ki") Or (Left(txtKiny.Text, 2) = "cy") Or (Left(txtKiny.Text, 2) = "gi") Then
    ws.Cells(iRow, 7).Value = Me.txtKiny.Value
End If
 
If (Left(txtKiny.Text, 2) = "in") Or (Left(txtKiny.Text, 3) = "inz") Or (Left(txtKiny.Text, 2) = "nz") Then
    ws.Cells(iRow, 8).Value = Me.txtKiny.Value
End If
If (Left(txtKiny.Text, 3) = "uru") Or (Left(txtKiny.Text, 3) = "urw") Or (Left(txtKiny.Text, 2) = "ru") Or (Left(txtKiny.Text, 2) = "rw") Then
    ws.Cells(iRow, 9).Value = Me.txtKiny.Value
End If
If (Left(txtKiny.Text, 3) = "aka") Or (Left(txtKiny.Text, 3) = "ak") Or (Left(txtKiny.Text, 3) = "aga") Or (Left(txtKiny.Text, 2) = "ka") Or (Left(txtKiny.Text, 2) = "k") Or (Left(txtKiny.Text, 2) = "ga") Then
    ws.Cells(iRow, 10).Value = Me.txtKiny.Value
End If
If (Left(txtKiny.Text, 3) = "utu") Or (Left(txtKiny.Text, 3) = "utw") Or (Left(txtKiny.Text, 3) = "udu") Or (Left(txtKiny.Text, 2) = "tu") Or (Left(txtKiny.Text, 2) = "tw") Or (Left(txtKiny.Text, 2) = "du") Then
    ws.Cells(iRow, 11).Value = Me.txtKiny.Value
End If
If (Left(txtKiny.Text, 3) = "ubu") Or (Left(txtKiny.Text, 3) = "ubw") Or (Left(txtKiny.Text, 2) = "bu") Or (Left(txtKiny.Text, 2) = "bw") Then
    ws.Cells(iRow, 12).Value = Me.txtKiny.Value
End If
    If (Left(txtKiny.Text, 3) = "uku") Or (Left(txtKiny.Text, 3) = "ukw") Or (Left(txtKiny.Text, 3) = "ugu") Or (Left(txtKiny.Text, 2) = "ku") Or (Left(txtKiny.Text, 2) = "kw") Or (Left(txtKiny.Text, 2) = "gu") Then
    ws.Cells(iRow, 13).Value = Me.txtKiny.Value
End If
 
Me.txtKiny.Value = ""
 Me.txtKiny.SetFocus
End Sub
 
Private Sub cmdClose_Click()
Unload Me
End Sub
merci de votre aide.
Fichiers attachés
Type de fichier : xls 20112113Amajyi.xls (66,0 Ko, 6 affichages)
jeph.net est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 14/12/2011, 19h29   #2
Expert Confirmé Sénior
 
Avatar de mercatog
 
Inscription : juillet 2008
Messages : 5 848
Détails du profil
Informations forums :
Inscription : juillet 2008
Messages : 5 848
Points : 13 907
Points : 13 907
Code :
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
Private Sub cmdAdd_Click()
Dim Str As String
Dim k As Integer
 
 
Str = Left(txtKiny.Text, 3)
Select Case Str
    Case "umu", "umw": k = 1
    Case "imi", "imy": k = 3
    Case "iri", "iry": k = 4
    Case "iki", "icy", "igi": k = 6
    Case "ibi", "iby": k = 7
        '...la suite des cas sur les 3 premières lettres
End Select
 
Str = Left(txtKiny.Text, 2)
Select Case Str
    Case "mu", "mw": k = 1
    Case "ab", "ba": k = 2
    Case "mi", "my": k = 3
    Case "ri", "ry": k = 4
    Case "am", "ma": k = 5
    Case "ki", "cy", "gi": k = 7
        '...la suite des cas sur les 2 premières lettres
End Select
 
If k > 0 Then
    With Worksheets("amajyi")
        .Cells(.Rows.Count, k).End(xlUp)(2) = Me.txtKiny.Value
    End With
End If
Me.txtKiny.Value = ""
Me.txtKiny.SetFocus
End Sub
__________________
Cordialement.
mercatog est déconnecté   Envoyer un message privé Réponse avec citation 20
Vieux 14/12/2011, 19h59   #3
Invité de passage
 
Homme
Étudiant
Inscription : décembre 2011
Messages : 14
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Rwanda

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2011
Messages : 14
Points : 4
Points : 4
Par défaut remplecement

Merci beaucoup Mercatog ma question est bien resolu avec votre aide merci en tout cas.mais ça va m'aider d'avantage si vous essayer un peu d'ajouter quelque commentaire pour m'explique comment les codes fonctionnent.
jeph.net est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h57.


 
 
 
 
Partenaires

Hébergement Web