I'm somewhat of a newbie at working with VBA code. I have a workbook where the users can edit cells that have a fill background of "rose". When they clear the field and enter a new value then hit "enter", the color changes to blue and a message box pops up. However, I have to assume that the users are naive and may clear the box in error, and wish to return to the original value (with a rose fill color).
With my code, this isn't possible using the "undo" button. If undoing via VBA can't be added I'd like some ideas on how to alert the user upon entering the cell to note the original value before clearing it and enter his/her own value.
Here's my code:
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Expenses").Range("B5").Value = Range("K49")
'This lookes for changes in pink cells and chenges them to blue
If Target.Interior.ColorIndex = 38 Then
MsgBox "Add a comment below. Make sure this is your final change. If you made a mistake and want to go back to the original value, exit and re-open the workbook."
Target.Interior.ColorIndex = 37
End If
End Sub
Thank you for any and all postings!
With my code, this isn't possible using the "undo" button. If undoing via VBA can't be added I'd like some ideas on how to alert the user upon entering the cell to note the original value before clearing it and enter his/her own value.
Here's my code:
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Expenses").Range("B5").Value = Range("K49")
'This lookes for changes in pink cells and chenges them to blue
If Target.Interior.ColorIndex = 38 Then
MsgBox "Add a comment below. Make sure this is your final change. If you made a mistake and want to go back to the original value, exit and re-open the workbook."
Target.Interior.ColorIndex = 37
End If
End Sub
Thank you for any and all postings!