FracinDean
Board Regular
- Joined
- Jul 11, 2011
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
Hello Forum, I'm trying to use the Worksheet_Change event to replace all cleared cells with a default formula. This allows users to override the default, or restore the default when they need to:
If Not Intersect(Target, Range("Data")) Is Nothing And Target.Value = "" Then
Range("DefaultFormula").Copy
ActiveSheet.Paste
ActiveSheet.Application.CutCopyMode = False
End If
Here are the results with various different regions selected:</SPAN>
Example1: Selected range is (D2:E2, G2) in that order, it does not copy the formula into the cleared cells.
Example2: Selected range is (G2, D2:E2) in that order, the code does copy the formula into all the cleared cells as desired.
The "IF" condition is not TRUE when the initial area has more than one cell.
Any suggestions would be appreciated.</SPAN>
If Not Intersect(Target, Range("Data")) Is Nothing And Target.Value = "" Then
Range("DefaultFormula").Copy
ActiveSheet.Paste
ActiveSheet.Application.CutCopyMode = False
End If
Here are the results with various different regions selected:</SPAN>
- Single cell selected and cleared -- works. </SPAN>
- Multiple cells selected and cleared -- doesn't work if the first area selected contains more than one cell. Otherwise, it works, no matter how many other areas are selected.</SPAN>
Example1: Selected range is (D2:E2, G2) in that order, it does not copy the formula into the cleared cells.
Example2: Selected range is (G2, D2:E2) in that order, the code does copy the formula into all the cleared cells as desired.
The "IF" condition is not TRUE when the initial area has more than one cell.
Any suggestions would be appreciated.</SPAN>