I have a sheet where I want to calculate a price in a range of cells (i18:i26) when a percentage value is entered in range (b18:b26).
If the user then wishes to input a price in range (i18:i26) I want the value of the cell in column b of the same row to change to zero.
The code below calculates my price when percentage is entered in range ColumnB but I cannot get the percentage to change to zero if I manually input a price. This means that when I input a percentage in another row the price I just changed resets according to the formula.
Any suggestions as how to achieve this would be greatly appreciated!
If the user then wishes to input a price in range (i18:i26) I want the value of the cell in column b of the same row to change to zero.
The code below calculates my price when percentage is entered in range ColumnB but I cannot get the percentage to change to zero if I manually input a price. This means that when I input a percentage in another row the price I just changed resets according to the formula.
Any suggestions as how to achieve this would be greatly appreciated!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("b18:b26")) Is Nothing Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Range("$i18:$i26").Formula = "=IF($b18>0,$g18-($g18*$b18),0)"
Application.EnableEvents = True
If Target.Cells = ("i18:i26") Then
Target.Offset(0, -7).Value = 0
End If
End Sub