is there anyone master in 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%
gross = basic+hra+conv - should calculate automatically
fileno shld generate automatically.
***************
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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

I would have a button on the form to run the code. Depending on the layout of the spreadsheet you would need something like


Code:
Private Sub CommandButton1_Click()
RANGE("A65536").end(xlup).offset(1,0).value=textbox1.text
End Sub

is this enough to be getting on with?
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Where do you want to put the files, and what sort of files are they (Excel, Text or something else)?
 

fanku

New Member
Joined
Sep 20, 2006
Messages
30
send me ur email address ...
i want to send u my excel file..so, u will get clear idea..
and ur help will gain my knowledge..

i want to learn excel-vba script..

Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,113,846
Messages
5,544,634
Members
410,626
Latest member
rkmadasu
Top