Good morning/afternoon to Y'ALL . Is it possible to save a row of data that you're getting ready to delete before you actually delete it?
The following macro allows the user to select a row of data from a listbox (ListBox1) on userform "frmRequest" and then delete the data from worksheet "Leave Request". I want to save the information to another worksheet "Deleted Data" before it's actually deleted. The NEW worksheet "Deleted Data" has 5 columns "A" to "E" and headers in "A1" to "E1" and the saved data starts in row 2 "A2" on down.
OR IS THERE AN EASIER WAY TO ACCOMPLISH THIS???
[VBA]Private Sub CommandButton1_Click()
Dim mpLastRow As Long
Application.EnableEvents = False
With frmRequest.ListBox1
'Check for selected item
If (.Value <> vbNullString) Then
'If more then one data rows
mpLastRow = xlLastRow("Leave Request")
If .ListIndex >= 0 Then
Range(.RowSource)(.ListIndex + 1, 1).EntireRow.Delete
'Update listbox
.RowSource = "'Leave Request'!A2:E" & mpLastRow
Else
MsgBox "Please Select Data"
End If
End If
End With
Application.EnableEvents = True
Unload Me
End Sub[/VBA]
</IMG>