Hi Friends..
I have created data entry form using excel-vba.
any one can tell me how can i save data into excel entries are done though VBA form, i am entering basic data.
File no :
name :
date of birth :
address :
basic :
hra :
conv :
pf = basic * 12%
MF = if pf > 10000 then mf = 780
gross = basic+hra+conv - should calculate automatically
fileno shld generate automatically.
***************These are my VBA CODE of EXCEL modeule...
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.id.Value) = "" Then
Me.id.SetFocus
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.id.Value
ws.Cells(iRow, 2).Value = Me.gender.Value
ws.Cells(iRow, 3).Value = Me.mname.Value
ws.Cells(iRow, 4).Value = Me.add1.Value
ws.Cells(iRow, 5).Value = Me.add2.Value
ws.Cells(iRow, 6).Value = Me.add3.Value
ws.Cells(iRow, 7).Value = Me.phone.Value
ws.Cells(iRow, 8).Value = Me.cell.Value
ws.Cells(iRow, 9).Value = Me.dob.Value
ws.Cells(iRow, 10).Value = Me.doj.Value
ws.Cells(iRow, 11).Value = Me.edu1.Value
ws.Cells(iRow, 12).Value = Me.coll1.Value
ws.Cells(iRow, 13).Value = Me.yr1.Value
ws.Cells(iRow, 14).Value = Me.edu2.Value
ws.Cells(iRow, 15).Value = Me.coll2.Value
ws.Cells(iRow, 16).Value = Me.yr2.Value
ws.Cells(iRow, 17).Value = Me.exp.Value
ws.Cells(iRow, 18).Value = Me.lastcomp.Value
ws.Cells(iRow, 19).Value = Me.lastdesig.Value
ws.Cells(iRow, 20).Value = Me.appointed.Value
ws.Cells(iRow, 21).Value = Me.grade.Value
ws.Cells(iRow, 22).Value = Me.dept.Value
ws.Cells(iRow, 23).Value = Me.loc.Value
ws.Cells(iRow, 24).Value = Me.hold.Value
' Salary Details
ws.Cells(iRow, 24).Value = Me.basic.Value
ws.Cells(iRow, 25).Value = Me.hra.Value
ws.Cells(iRow, 26).Value = Me.conv.Value
ws.Cells(iRow, 27).Value = Me.others.Value
ws.Cells(iRow, 28).Value = Me.mf.Value
***************************** till here i can do it...but how to do following calculation and save to excel..??
ws.Cells(iRow, 29).Value = Me.pf.Value
ws.Cells(iRow, 30).Value = Me.esic.Value
ws.Cells(iRow, 31).Value = Me.gross.Value
'ws.Cells(iRow, 32).Value = Me.fbonus.Value
ws.Cells(iRow, 38).Value = Me.driver.Value
ws.Cells(iRow, 39).Value = Me.mobile.Value
ws.Cells(iRow, 40).Value = Me.laptop.Value
'clear the data
Me.id.Value = ""
Me.mname.Value = ""
Me.dob.Value = ""
Me.id.Value = ""
Me.gender.Value = ""
Me.mname.Value = ""
Me.add1.Value = ""
Me.add2.Value = ""
Me.add3.Value = ""
Me.phone.Value = ""
Me.cell.Value = ""
Me.dob.Value = ""
Me.doj.Value = ""
Me.edu1.Value = ""
Me.coll1.Value = ""
Me.yr1.Value = ""
Me.edu2.Value = ""
Me.coll2.Value = ""
Me.yr2.Value = ""
Me.exp.Value = ""
Me.lastcomp.Value = ""
Me.lastdesig.Value = ""
Me.appointed.Value = ""
Me.grade.Value = ""
Me.dept.Value = ""
Me.loc.Value = ""
Me.hold.Value = ""
Me.id.SetFocus
End Sub
***************
regards
I have created data entry form using excel-vba.
any one can tell me how can i save data into excel entries are done though VBA form, i am entering basic data.
File no :
name :
date of birth :
address :
basic :
hra :
conv :
pf = basic * 12%
MF = if pf > 10000 then mf = 780
gross = basic+hra+conv - should calculate automatically
fileno shld generate automatically.
***************These are my VBA CODE of EXCEL modeule...
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.id.Value) = "" Then
Me.id.SetFocus
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.id.Value
ws.Cells(iRow, 2).Value = Me.gender.Value
ws.Cells(iRow, 3).Value = Me.mname.Value
ws.Cells(iRow, 4).Value = Me.add1.Value
ws.Cells(iRow, 5).Value = Me.add2.Value
ws.Cells(iRow, 6).Value = Me.add3.Value
ws.Cells(iRow, 7).Value = Me.phone.Value
ws.Cells(iRow, 8).Value = Me.cell.Value
ws.Cells(iRow, 9).Value = Me.dob.Value
ws.Cells(iRow, 10).Value = Me.doj.Value
ws.Cells(iRow, 11).Value = Me.edu1.Value
ws.Cells(iRow, 12).Value = Me.coll1.Value
ws.Cells(iRow, 13).Value = Me.yr1.Value
ws.Cells(iRow, 14).Value = Me.edu2.Value
ws.Cells(iRow, 15).Value = Me.coll2.Value
ws.Cells(iRow, 16).Value = Me.yr2.Value
ws.Cells(iRow, 17).Value = Me.exp.Value
ws.Cells(iRow, 18).Value = Me.lastcomp.Value
ws.Cells(iRow, 19).Value = Me.lastdesig.Value
ws.Cells(iRow, 20).Value = Me.appointed.Value
ws.Cells(iRow, 21).Value = Me.grade.Value
ws.Cells(iRow, 22).Value = Me.dept.Value
ws.Cells(iRow, 23).Value = Me.loc.Value
ws.Cells(iRow, 24).Value = Me.hold.Value
' Salary Details
ws.Cells(iRow, 24).Value = Me.basic.Value
ws.Cells(iRow, 25).Value = Me.hra.Value
ws.Cells(iRow, 26).Value = Me.conv.Value
ws.Cells(iRow, 27).Value = Me.others.Value
ws.Cells(iRow, 28).Value = Me.mf.Value
***************************** till here i can do it...but how to do following calculation and save to excel..??
ws.Cells(iRow, 29).Value = Me.pf.Value
ws.Cells(iRow, 30).Value = Me.esic.Value
ws.Cells(iRow, 31).Value = Me.gross.Value
'ws.Cells(iRow, 32).Value = Me.fbonus.Value
ws.Cells(iRow, 38).Value = Me.driver.Value
ws.Cells(iRow, 39).Value = Me.mobile.Value
ws.Cells(iRow, 40).Value = Me.laptop.Value
'clear the data
Me.id.Value = ""
Me.mname.Value = ""
Me.dob.Value = ""
Me.id.Value = ""
Me.gender.Value = ""
Me.mname.Value = ""
Me.add1.Value = ""
Me.add2.Value = ""
Me.add3.Value = ""
Me.phone.Value = ""
Me.cell.Value = ""
Me.dob.Value = ""
Me.doj.Value = ""
Me.edu1.Value = ""
Me.coll1.Value = ""
Me.yr1.Value = ""
Me.edu2.Value = ""
Me.coll2.Value = ""
Me.yr2.Value = ""
Me.exp.Value = ""
Me.lastcomp.Value = ""
Me.lastdesig.Value = ""
Me.appointed.Value = ""
Me.grade.Value = ""
Me.dept.Value = ""
Me.loc.Value = ""
Me.hold.Value = ""
Me.id.SetFocus
End Sub
***************
regards