is there VBA Master of excel

fanku

New Member
Joined
Sep 20, 2006
Messages
30
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
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
This:

ws.Cells(iRow, 29).Value = Me.pf.Value

would be:

ws.Cells(iRow, 29).Value = Val(Me.basic.Value) * 0.12

Hope that gets you started.
 

fanku

New Member
Joined
Sep 20, 2006
Messages
30
Respected Sir,

lets assume i am entering basic, hra, conve. but as soon as i reach to others_allow, after entering other allow my gross should be calculated automaticallly and shld disply on my form...??

apart from that my id shld be get generated automatically...??

can i get ur email address ..i wish to send u my excel form..
i m sure i can learn good comands of VB frou u..

UR prompt reply in this regards will be appriciated..


Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,114,037
Messages
5,545,667
Members
410,697
Latest member
srishtijain0708
Top