Simon Campbell
New Member
- Joined
- Oct 12, 2021
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
I Have a USERFORM with a CommandButton that deletes a row from a worksheet called ANALYSISDB. The WORKBOOK aslo has a sheets called PLOT. When the DELETE command is run it deletes the row from the PLOT sheet and not the ANALYSISDB sheets, below is the Code I have used. For all other Command Button actions (SAVE,UPDATE) they seem to work properly. Any suggestions.
VBA Code:
'DELETE BUTTON CODE
Private Sub cmd_Delete_Click()
Dim x As Long
Dim Y As Long
x = ThisWorkbook.Worksheets("ANALYSISDB").Range("A" & Rows.Count).End(xlUp).Row
For Y = 2 To x
If ThisWorkbook.Worksheets("ANALYSISDB").Cells(Y, 1).Value = txt_Search.Text Then
Rows(Y).Delete
End If
Next Y
'Clear Data Entry Form
Me.txt_Search.Value = "-"
Me.txt_Name.Value = "-"
Me.cmb_Phase.Value = "0"
Me.txt_Crest.Value = "0"
Me.txt_GOC.Value = "0"
Me.txt_HWC.Value = "0"
Me.txt_OP.Value = "0"
Me.txt_GasGrad.Value = "0"
Me.txt_OilGrad.Value = "0"
Me.txt_WaterGrad.Value = "0"
Me.txt_RefWell.Value = "-"
Me.chbDisplay.Value = False
Me.chbLabel.Value = False
MsgBox "Data has been deleted", vbInformation
txt_Name.SetFocus
End Sub
Last edited by a moderator: