Tester le contenu d'un textbox
Butterfly_67
Messages postés
4
Statut
Membre
-
Butterfly_67 Messages postés 4 Statut Membre -
Butterfly_67 Messages postés 4 Statut Membre -
Bonjour,
Je suis débutante en VBA et j'ai besoin d'un coup de main svp.
J'ai 1 tableau dont la 1ère ligne contient des numéros de contrats sous la forme xxxx-xx. J'ai un userform dans lequel je rentre ces numéros de contrat; je valide l'entrée par un bouton "VALIDER". Ensuite je veux tester que ce numéro xxxx-xx n'existe pas déja dans ma liste ... mais là ca coince ...
Private Sub CommandButton2_Click()
Dim c
Dim d
Windows("Production DAK 2010 (Enregistré automatiquement).xlsm").Activate
Sheets("MISE EN PROD").Select
Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.EntireColumn.Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Unload CONTRAT
With Worksheets(1).Range("a1").End(xlToRight)
Set c = .Find(d, LookIn:=xlValues)
If Not c Is Nothing Then
Range("A1").End(xlToRight).Offset(0, 1).Value = TextBox1.Value
End If
End With
If d = " " Then MsgBox "Vous devez saisir un N° de contrat !!"
CONTRAT.Show
With Worksheets(1).Range("a1").End(xlToRight)
Set c = .Find(d, LookIn:=xlValues)
If c Is d Then
MsgBox "Contrat éxistant !!"
ActiveCell.ClearContents
ActiveCell.EntireColumn.Delete
Range("A1").Select
CONTRAT.Show
TextBox1 = " "
End If
End With
End Sub
Merci pour votre aide.
Je suis débutante en VBA et j'ai besoin d'un coup de main svp.
J'ai 1 tableau dont la 1ère ligne contient des numéros de contrats sous la forme xxxx-xx. J'ai un userform dans lequel je rentre ces numéros de contrat; je valide l'entrée par un bouton "VALIDER". Ensuite je veux tester que ce numéro xxxx-xx n'existe pas déja dans ma liste ... mais là ca coince ...
Private Sub CommandButton2_Click()
Dim c
Dim d
Windows("Production DAK 2010 (Enregistré automatiquement).xlsm").Activate
Sheets("MISE EN PROD").Select
Range("A1").Select
Selection.End(xlToRight).Select
ActiveCell.EntireColumn.Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Unload CONTRAT
With Worksheets(1).Range("a1").End(xlToRight)
Set c = .Find(d, LookIn:=xlValues)
If Not c Is Nothing Then
Range("A1").End(xlToRight).Offset(0, 1).Value = TextBox1.Value
End If
End With
If d = " " Then MsgBox "Vous devez saisir un N° de contrat !!"
CONTRAT.Show
With Worksheets(1).Range("a1").End(xlToRight)
Set c = .Find(d, LookIn:=xlValues)
If c Is d Then
MsgBox "Contrat éxistant !!"
ActiveCell.ClearContents
ActiveCell.EntireColumn.Delete
Range("A1").Select
CONTRAT.Show
TextBox1 = " "
End If
End With
End Sub
Merci pour votre aide.
A voir également:
- Tester le contenu d'un textbox
- Flash drive tester - Télécharger - Divers Utilitaires
- Tester son pc - Guide
- Le fichier à télécharger correspond au contenu brut d’un courrier électronique. de quel pays a été envoyé ce message ? - Guide
- Tester composant pc - Guide
- Fusionner deux cellules excel en gardant le contenu - Guide
2 réponses
Bonjour,
Essayez ceci et adaptez le
Private Sub CommandButton2_Click()
Dim c, d, x
Windows("Production DAK 2010 (Enregistré automatiquement).xlsm").Activate
Sheets("MISE EN PROD").Activate
d = TextBox1.Value
If d = "" Then
MsgBox "Vous devez saisir un N° de contrat !!"
Exit Sub
End If
With Worksheets(1).Range("a1").End(xlToRight)
x = Selection.Columns.Count
Set c = .Find(d, LookIn:=xlValues)
If Not c Is Nothing Then
' Contrat deja inscrit
MsgBox "Contrat éxistant !!"
TextBox1 = ""
Else
'Ecriture nouveau contrat
Cells(1, (x + 1)).Value = d 'TextBox1.Value
End If
End With
End Sub
Bonne continuation.
Essayez ceci et adaptez le
Private Sub CommandButton2_Click()
Dim c, d, x
Windows("Production DAK 2010 (Enregistré automatiquement).xlsm").Activate
Sheets("MISE EN PROD").Activate
d = TextBox1.Value
If d = "" Then
MsgBox "Vous devez saisir un N° de contrat !!"
Exit Sub
End If
With Worksheets(1).Range("a1").End(xlToRight)
x = Selection.Columns.Count
Set c = .Find(d, LookIn:=xlValues)
If Not c Is Nothing Then
' Contrat deja inscrit
MsgBox "Contrat éxistant !!"
TextBox1 = ""
Else
'Ecriture nouveau contrat
Cells(1, (x + 1)).Value = d 'TextBox1.Value
End If
End With
End Sub
Bonne continuation.
Butterfly_67
Messages postés
4
Statut
Membre
Merci mais ... j'ai beau essayer, ca ne marche pas car il me met sans arrêt "contrat existant".
ReBonjour,
Ceci devrait aller
Private Sub CommandButton2_Click()
Dim c, d, x
Windows("Production DAK 2010 (Enregistré automatiquement).xlsm").Activate
Sheets("MISE EN PROD").Activate
d = TextBox1.Value
If d = "" Then
MsgBox "Vous devez saisir un N° de contrat !!"
Exit Sub
End If
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
x = Selection.Columns.Count
With Worksheets(1).Range(Cells(1, 1), Cells(1, x))
Set c = .Find(d, LookIn:=xlValues)
If Not c Is Nothing Then
'Contrat deja inscrit
MsgBox "Contrat éxistant !!"
TextBox1 = ""
Else
'Ecriture nouveau contrat
Cells(1, (x + 1)).Value = d
TextBox1 = ""
End If
End With
End Sub
Bonne continuation.
Ceci devrait aller
Private Sub CommandButton2_Click()
Dim c, d, x
Windows("Production DAK 2010 (Enregistré automatiquement).xlsm").Activate
Sheets("MISE EN PROD").Activate
d = TextBox1.Value
If d = "" Then
MsgBox "Vous devez saisir un N° de contrat !!"
Exit Sub
End If
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
x = Selection.Columns.Count
With Worksheets(1).Range(Cells(1, 1), Cells(1, x))
Set c = .Find(d, LookIn:=xlValues)
If Not c Is Nothing Then
'Contrat deja inscrit
MsgBox "Contrat éxistant !!"
TextBox1 = ""
Else
'Ecriture nouveau contrat
Cells(1, (x + 1)).Value = d
TextBox1 = ""
End If
End With
End Sub
Bonne continuation.