Bonjour,Bonjour le Forum,
Via un formulaire, j''encode des données... quand je transfère les données vers les cellules tout ce qui numérique (texteBox3 et 4), se retrouve en chaine de caractère...
Pouvez-vous m'aider ?
Oli
'-----------
'-----------
For j = 1 To 7
If IsNumeric(Controls("textBox" & j)) Then
Cells(cell.Row, j) = CLng(Controls("textBox" & j))
Else
Cells(cell.Row, j) = Controls("textBox" & j)
End If
Next j
'-----------
'-----------'
Re..Bonjour Jacky67,
j'ai essayé avec ta proposition et j'ai une erreur de type variable objet ou variable de block with non définie sur la ligne après le else
Oli
Re..re ,
en ligne ?
OLi
Private Sub CmdAjout_Click()
Set cell = Range("A3:A" & Application.Max(3, Range("A" & Rows.Count).End(xlUp).Row)) _
.Find(CmbNom, lookat:=xlWhole)
If Not cell Is Nothing Then
rep = MsgBox("Etes-vous sûr de vouloir modifier les données de " & CmbNom & " ?", 20)
If rep = 7 Then Exit Sub
End If
For j = 1 To 7
If IsNumeric(Controls("textBox" & j)) = True Then
Cells(cell.Row, j) = CLng(Controls("textBox" & j))
Else
Cells(cell.Row, j) = Controls("textBox" & j)
End If
Next j
MsgBox "Les données de " & CmbNom & " ont été modifiées.", 64
Unload Me
End Sub
If IsDate(Controls("textBox" & j)) = True Then
Private Sub CmdNouv_Click()
Dim j As Integer
Set cell = Range("A3:A" & Application.Max(3, Range("A" & Rows.Count).End(xlUp).Row)) _
.Find(CmbNom, lookat:=xlWhole)
If Not cell Is Nothing Then
MsgBox CmbNom & " Existe déjà." & Chr(13) & "Vous ne pouvez que le modifier ou le supprimer", 16
Exit Sub
End If
lgn = Application.Max(3, Range("A" & Rows.Count).End(xlUp)(2).Row)
For j = 1 To 7
If IsNumeric(Controls("textBox" & j)) Then
Cells(cell.Row, j) = CLng(Controls("textBox" & j))
Else
Cells(cell.Row, j) = Controls("textBox" & j)
End If
Next j
Range("A3:G" & lgn).Sort key1:=Range("A3"), order1:=xlAscending, Header:=xlNo
Re..Bonjour JM27,
VB:Private Sub CmdNouv_Click() Dim j As Integer Set cell = Range("A3:A" & Application.Max(3, Range("A" & Rows.Count).End(xlUp).Row)) _ .Find(CmbNom, lookat:=xlWhole) If Not cell Is Nothing Then MsgBox CmbNom & " Existe déjà." & Chr(13) & "Vous ne pouvez que le modifier ou le supprimer", 16 Exit Sub End If lgn = Application.Max(3, Range("A" & Rows.Count).End(xlUp)(2).Row) For j = 1 To 7 If IsNumeric(Controls("textBox" & j)) Then Cells(cell.Row, j) = CLng(Controls("textBox" & j)) Else Cells(cell.Row, j) = Controls("textBox" & j) End If Next j Range("A3:G" & lgn).Sort key1:=Range("A3"), order1:=xlAscending, Header:=xlNo
si cell est défini...
Oli
Re...Bonsoir Jacky67, JM27,
Dans les deux cas, quand il transfère dans la cellule, c'est toujours sous forme de texte et non un nombre....
Regarde la pièce jointe 1087166
OLi