Hi, i want to display data in excel worksheet by using user inputbox for emp name,emp id, and emp phone using VBA UserForms.but when i give data in inputbox for these data the data will display in excel worksheet but when i give next record in userforms the previous displayed data would be replaced by next record data.means i want to ask the user for number of records in inputbox then display those data in excel sheet.i am posting my code.please help me.thanks
Private Sub cmdOK_Click()
Dim empname As String
Dim empid As Integer
Dim empphn As Long
If txtEmpName = "" Then
MsgBox "Please enter employee name"
txtEmpName.SetFocus
ElseIf txtEmpId = "" Then
MsgBox "Please enter employee id"
txtEmpId.SetFocus
ElseIf txtEmpPhn = "" Then
MsgBox "Please enter employee phone"
txtEmpPhn.SetFocus
Else
empname = txtEmpName.Value
empid = txtEmpId.Value
empphn = txtEmpPhn.Value
End If
Range("A1").Value = txtEmpName.text
Range("B1").Value = txtEmpId.text
Range("C1").Value = txtEmpPhn.text
End Sub
Private Sub cmdNextRecord_Click()
txtEmpName.text = ""
txtEmpId.text = ""
txtEmpPhn.text = ""
Range("A2").Value = txtEmpName.text
Range("B2").Value = txtEmpId.text
Range("C2").Value = txtEmpPhn.text
End Sub
i also post the image of userform.please find that
please provide the code for this program.thanks
Bookmarks