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
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,222,170
Messages
6,164,377
Members
451,886
Latest member
elpepe1970

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