How to: create userform in excel in hindi Part - 1


My first tutorial showing how to create a simple user form using excel. Thanks for watching.
The code needed for the "add details" button:

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a Name number
If Trim(Me.example1.Value) = "" Then
Me.example1.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.example1.Value
ws.Cells(iRow, 2).Value = Me.example2.Value
ws.Cells(iRow, 3).Value = Me.example3.Value
ws.Cells(iRow, 4).Value = Me.example4.Value

MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.example1.Value = ""
Me.example2.Value = ""
Me.example3.Value = ""
Me.example4.Value = ""
Me.example1.SetFocus

Share this

Related Posts

Previous
Next Post »