Bern494
07-11-2007, 08:26 AM
Hi
I seem to having difficulty with my code. What I am trying to achieve is this:
My parts entry form works ok but I need a delete from time to time a part from the list. I have placed a delete button on the form, used for entering a new part. I would also like a warning message along the lines of 'Are you sure you want to delete this part' All my code from the form shown below.
Private Sub cmdCancel_Click()
Unload Me
Sheets("Imput").Select
Range("B2").Select
End Sub
Private Sub UserForm_Initialize()
txtpartn0.Value = ""
txtcost.Value = ""
txtnetcost.Value = ""
End Sub
Private Sub cmdpartentry_Click()
Application.Calculation = xlCalculationManual
Dim c As Range
With Sheets("Parts Issue").Columns("A:A")
Set c = .Find("ZZ", LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
c.Value = txtpartn0.Value
c.Offset(0, 1) = txtcost.Value
c.Offset(0, 2) = txtnetcost.Value
End If
End With
Application.Calculation = xlCalculationAutomatic
Unload frmpartenter
Call SortParts
End Sub
Private Sub cmdpartdelete_Click()
Application.Calculation = xlCalculationManual
Dim c As Range
With Sheets("Parts Issue").Columns("A:A")
Set c = .Find("ZZ", LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
If Value = c Then
cell.EntireRow.Delete
End If
End If
End With
Application.Calculation = xlCalculationAutomatic
Unload frmpartenter
Call SortParts
End Sub
'ZZ is a default name in the list for sorting purposes.
Many thanks
Bern (Using Excel 2003)
I seem to having difficulty with my code. What I am trying to achieve is this:
My parts entry form works ok but I need a delete from time to time a part from the list. I have placed a delete button on the form, used for entering a new part. I would also like a warning message along the lines of 'Are you sure you want to delete this part' All my code from the form shown below.
Private Sub cmdCancel_Click()
Unload Me
Sheets("Imput").Select
Range("B2").Select
End Sub
Private Sub UserForm_Initialize()
txtpartn0.Value = ""
txtcost.Value = ""
txtnetcost.Value = ""
End Sub
Private Sub cmdpartentry_Click()
Application.Calculation = xlCalculationManual
Dim c As Range
With Sheets("Parts Issue").Columns("A:A")
Set c = .Find("ZZ", LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
c.Value = txtpartn0.Value
c.Offset(0, 1) = txtcost.Value
c.Offset(0, 2) = txtnetcost.Value
End If
End With
Application.Calculation = xlCalculationAutomatic
Unload frmpartenter
Call SortParts
End Sub
Private Sub cmdpartdelete_Click()
Application.Calculation = xlCalculationManual
Dim c As Range
With Sheets("Parts Issue").Columns("A:A")
Set c = .Find("ZZ", LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
If Value = c Then
cell.EntireRow.Delete
End If
End If
End With
Application.Calculation = xlCalculationAutomatic
Unload frmpartenter
Call SortParts
End Sub
'ZZ is a default name in the list for sorting purposes.
Many thanks
Bern (Using Excel 2003)