My code below is supposed to pull up a prompt when deleting a cell in a particular row.
Before the deletion is done, a message box pops up and asks if they're sure.
It should then copy the value of that cell before deleting and use that value as a variable for another macro that deletes cells in another worksheet.
After I run the code as is, I then get a type mismatch error. Why is that?
Otherwise, the row does get deleted.
Here is the code:
Any help would be greatly appreciated.
Before the deletion is done, a message box pops up and asks if they're sure.
It should then copy the value of that cell before deleting and use that value as a variable for another macro that deletes cells in another worksheet.
After I run the code as is, I then get a type mismatch error. Why is that?
Otherwise, the row does get deleted.
Here is the code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
[COLOR=#008000]' If target column is B, is below the header row AND it's new value is blank then...[/COLOR]
If Target.Column = 2 And Target.Row > 1 And Target.Value = "" Then
[COLOR=#008000]' Clear contents of row[/COLOR]
ans = MsgBox("Are you sure you want to Delete......This cannot Be Undone !!!", vbYesNo)
If ans = vbYes Then
[B][COLOR=#ff0000]'How do I select Column 2, Row active cell and copy the value?[/COLOR][/B]
[B][COLOR=#ff0000]'How do I make the value into variable YYY?[/COLOR][/B]
Rows(ActiveCell.Row).EntireRow.Delete
Exit Sub
End If
End If
End Sub
Any help would be greatly appreciated.