#name? error

DharmeshKP

New Member
Joined
Feb 15, 2020
Messages
34
Office Version
  1. 2007
Platform
  1. 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
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I highly recommend you use "Option Explicit" at the top of each module, and in Tools->Options of your VBE interface, check the "Require Variable Declarations" box.

Maybe you need to use y.Rows.Count instead of simply Rows.Count

On which line are you getting the error?
 
Upvote 0
There is no error in code but the result value in database excel file A column display "#Name?"
Pl help me sort out this.
Basically I need age but if I simple write 30 yr and patient come next time after 1 yr it will remain same. So I need age based on DOB so that excel autocalculates current age.
 
Upvote 0
I have added option explicit
Now it show "#Value!" error
pl help me
 
Upvote 0
I highly recommend you use "Option Explicit" at the top of each module, and in Tools->Options of your VBE interface, check the "Require Variable Declarations" box.

Maybe you need to use y.Rows.Count instead of simply Rows.Count

On which line are you getting the error?



I have added option explicit
Now it show "#Value!" error
pl help me
No error in code
 
Upvote 0
.Cells(x + 1, "A").Value = [=DATE(YEAR(TODAY())-Val(textbox5.value),MONTH(TODAY()),DAY(TODAY()))]

Try replacing the line above with.

.Cells(x + 1, "A").Value = DateSerial(Year(Date) - Val(textbox5.Value), Month(Date), Day(Date))
 
Upvote 0
For reference when using square brackets to evaluate a formula, you cannot use variables (ie the textbox value)
 
Upvote 0
Thanks for replay
This formula worked But I worked in a diffierent way and got it sort out
Thanks a lot once again
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top