Hi everyone,
I have a userform wher i use a unique ID and two option buttons.
I would like to distribute the data in two tables. If optionbutton 1 is true then data goes in table 1 and if optionbutton 2 is true then data goes in table two. The Id number lose it's count when data goes in table 2 and restart from 1.
Any help?
Here the code and the userform
Private Sub CommandButton1_Click()
Dim LstRw As Long
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
Me.TextBox1.Value = Cells(LstRw, "A").Value + 1
TextBox3.Value = Format(Now(), "dd-mm-yy _ hh:mm")
End Sub
Private Sub CommandButton2_Click()
If TextBox2 = "" Then
MsgBox ("Appuyer sur Nouveau")
Else
If Sheets("Feuil1").Range("A1") = "" Then
Sheets("Feuil1").Range("A1") = TextBox1
Else
Sheets("Feuil1").ListObjects(1).ListRows.Add
End If
dlt = Sheets("Feuil1").Range("A1048576").End(xlUp).Row
If OptionButton1.Value = True Then
Sheets("Feuil1").Range("A" & dlt) = TextBox1
Sheets("Feuil1").Range("B" & dlt) = TextBox2
Sheets("Feuil1").Range("C" & dlt) = TextBox3
Else
Sheets("Feuil1").Range("F" & dlt) = TextBox1
Sheets("Feuil1").Range("G" & dlt) = TextBox2
Sheets("Feuil1").Range("H" & dlt) = TextBox3
End If
End If
End Sub
Private Sub TextBox3_Change()
TextBox3.Value = Format(Now(), "dd/mm/yy _ hh:mm")
End Sub
I have a userform wher i use a unique ID and two option buttons.
I would like to distribute the data in two tables. If optionbutton 1 is true then data goes in table 1 and if optionbutton 2 is true then data goes in table two. The Id number lose it's count when data goes in table 2 and restart from 1.
Any help?
Here the code and the userform
Private Sub CommandButton1_Click()
Dim LstRw As Long
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
Me.TextBox1.Value = Cells(LstRw, "A").Value + 1
TextBox3.Value = Format(Now(), "dd-mm-yy _ hh:mm")
End Sub
Private Sub CommandButton2_Click()
If TextBox2 = "" Then
MsgBox ("Appuyer sur Nouveau")
Else
If Sheets("Feuil1").Range("A1") = "" Then
Sheets("Feuil1").Range("A1") = TextBox1
Else
Sheets("Feuil1").ListObjects(1).ListRows.Add
End If
dlt = Sheets("Feuil1").Range("A1048576").End(xlUp).Row
If OptionButton1.Value = True Then
Sheets("Feuil1").Range("A" & dlt) = TextBox1
Sheets("Feuil1").Range("B" & dlt) = TextBox2
Sheets("Feuil1").Range("C" & dlt) = TextBox3
Else
Sheets("Feuil1").Range("F" & dlt) = TextBox1
Sheets("Feuil1").Range("G" & dlt) = TextBox2
Sheets("Feuil1").Range("H" & dlt) = TextBox3
End If
End If
End Sub
Private Sub TextBox3_Change()
TextBox3.Value = Format(Now(), "dd/mm/yy _ hh:mm")
End Sub