Forum Discussion
hrh_dash
Oct 02, 2022Iron Contributor
IF function does not populate when condition met
Would like to know what is wrong with the IF function for the code below as it does not populate the expected text "waive admin fee" when condition is met.. Private Sub Worksheet_Change(ByVal Ta...
- Oct 04, 2022
Wouldn't it be easier to enter the following formula in L2 and fill down?
=IF(AND(K2>0,K2<=10),"waive admin fee","")If you prefer the event procedure:
Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range If Not Intersect(Range("K2:K" & Rows.Count), Target) Is Nothing Then Application.ScreenUpdating = False Application.EnableEvents = False For Each rng In Intersect(Range("K2:K" & Rows.Count), Target) If rng.Value > 0 And rng.Value <= 10 Then rng.Offset(0, 1).Value = "waive admin fee" Else rng.Offset(0, 1).ClearContents End If Next rng Application.EnableEvents = True Application.ScreenUpdating = True End If End Sub
hrh_dash
Oct 04, 2022Iron Contributor
,
1. Yes, i would like to react to changes in column K and
2. Column K does not contain formulas just data
1. Yes, i would like to react to changes in column K and
2. Column K does not contain formulas just data
HansVogelaar
Oct 04, 2022MVP
Wouldn't it be easier to enter the following formula in L2 and fill down?
=IF(AND(K2>0,K2<=10),"waive admin fee","")
If you prefer the event procedure:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Range("K2:K" & Rows.Count), Target) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each rng In Intersect(Range("K2:K" & Rows.Count), Target)
If rng.Value > 0 And rng.Value <= 10 Then
rng.Offset(0, 1).Value = "waive admin fee"
Else
rng.Offset(0, 1).ClearContents
End If
Next rng
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
- hrh_dashOct 05, 2022Iron Contributor,thanks and appreciate the help!