Hi folks,
Would you help me to write a vba, so it can run the formula in column Y depending on the dynamic column X cells in each row (from X5 to X last row)?
Meaning, if X5 smth run in Y5 the formula, then if X6 is smth run formula in Y6 and so on.
I'm trying the following, but it works only if cell X5 changes, however I want to run to each row.
Hope I'm clear enough
Thanks!
Would you help me to write a vba, so it can run the formula in column Y depending on the dynamic column X cells in each row (from X5 to X last row)?
Meaning, if X5 smth run in Y5 the formula, then if X6 is smth run formula in Y6 and so on.
I'm trying the following, but it works only if cell X5 changes, however I want to run to each row.
Hope I'm clear enough
VBA Code:
Sub MyMacro()
Dim lr As Long
Dim r As Long
Application.ScreenUpdating = False
' Find last row in column I with data
lr = Cells(Rows.Count, "X").End(xlUp).Row
' Loop through all rows
For r = 2 To lr
' Check to see if column X is not blank
If Cells(r, "X") <> "" Then
' Populate column Y with formula
Cells(r, "Y").Formula = "=INDEX(Sheet8!$G$2:$G$22,MATCH(1,(X5>=Sheet8!$E$2:$E$22)*(X5<=Sheet8!$F$2:$F$22),0))"
End If
Next r
Application.ScreenUpdating = True
End Sub
Thanks!
Last edited by a moderator: