DharmeshKP
New Member
- Joined
- Feb 15, 2020
- Messages
- 34
- Office Version
- 2007
- Platform
- Windows
I have developed excel based softwere. There is an error of name. I want to get DOB from age in userform. Dode do not show any bug problem but database sheet show error"#Name?".Please help me to sort out this problem. My code is given below.
VBA Code:
Private Sub CommandButton3_Click()
Dim x As Long
Dim y As Worksheet
Dim c As Range
Set y = Sheets("Database")
x = y.Range("B" & Rows.Count).End(xlUp).Row
lrow = y.Cells(Rows.Count, "B").End(xlUp).Offset(1, 0).Row
With y.Range(y.Cells(1, 2), y.Cells(lrow, 2))
Set c = .Find(Me.TextBox1.Value, LookIn:=xlValues, LookAt:=xlWhole)
End With
If c Is Nothing Then
With y
.Cells(x + 1, "B").Value = TextBox1.Text
.Cells(x + 1, "C").Value = TextBox2.Text
.Cells(x + 1, "D").Value = TextBox3.Text
.Cells(x + 1, "E").Value = TextBox4.Text
.Cells(x + 1, "F").Value = TextBox5.Text
.Cells(x + 1, "G").Value = TextBox6.Text
.Cells(x + 1, "H").Value = TextBox7.Text
.Cells(x + 1, "I").Value = TextBox8.Text
.Cells(x + 1, "J").Value = TextBox9.Text
.Cells(x + 1, "K").Value = TextBox10.Text
.Cells(x + 1, "L").Value = TextBox11.Text
.Cells(x + 1, "M").Value = TextBox12.Text
.Cells(x + 1, "A").Value = [=DATE(YEAR(TODAY())-Val(textbox5.value),MONTH(TODAY()),DAY(TODAY()))]
End With
UserForm3.Show
With UserForm3
UserForm3.TextBox1.Text = UserForm2.TextBox1.Text
End With
Else: MsgBox TextBox1.Text & "is already exist "
Exit Sub
End If
End Sub