ebincharles
New Member
- Joined
- Feb 22, 2010
- Messages
- 10
Hey!
I use excel 2003 for data entry.All the data are stored in "Data" sheet. Like this Hundred of entry i need to enter. And I need to edit these entry by bring back to the form and store it again in same row of the sheet.
below is my code to save data:
Option Explicit
Private Sub cmdAdd_Click()
Dim lRow As Long
Dim lPart As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
'find first empty row in database
lRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox3.Value
.Cells(lRow, 4).Value = Me.TextBox4.Value
.Cells(lRow, 5).Value = Me.TextBox5.Value
.Cells(lRow, 6).Value = Me.TextBox6.Value
.Cells(lRow, 7).Value = Me.TextBox7.Value
.Cells(lRow, 8).Value = Me.TextBox8.Value
.Cells(lRow, 9).Value = Me.TextBox9.Value
.Cells(lRow, 10).Value = Me.TextBox10.Value
.Cells(lRow, 11).Value = Me.TextBox11.Value
End With
'clear the data
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
Me.TextBox9.Value = ""
Me.TextBox10.Value = ""
Me.TextBox11.Value = ""
Me.TextBox1.SetFocus
End Sub
I tried many ways for my sheet. But i cannot. Can u help me?
Regards
Charles
I use excel 2003 for data entry.All the data are stored in "Data" sheet. Like this Hundred of entry i need to enter. And I need to edit these entry by bring back to the form and store it again in same row of the sheet.
below is my code to save data:
Code:
Private Sub cmdAdd_Click()
Dim lRow As Long
Dim lPart As Long
Dim ws As Worksheet
Set ws = Worksheets("Data")
'find first empty row in database
lRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.TextBox1.Value) = "" Then
Me.TextBox1.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox3.Value
.Cells(lRow, 4).Value = Me.TextBox4.Value
.Cells(lRow, 5).Value = Me.TextBox5.Value
.Cells(lRow, 6).Value = Me.TextBox6.Value
.Cells(lRow, 7).Value = Me.TextBox7.Value
.Cells(lRow, 8).Value = Me.TextBox8.Value
.Cells(lRow, 9).Value = Me.TextBox9.Value
.Cells(lRow, 10).Value = Me.TextBox10.Value
.Cells(lRow, 11).Value = Me.TextBox11.Value
End With
'clear the data
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
Me.TextBox9.Value = ""
Me.TextBox10.Value = ""
Me.TextBox11.Value = ""
Me.TextBox1.SetFocus
End Sub
Code:
I tried many ways for my sheet. But i cannot. Can u help me?
Regards
Charles