1

=IF(AY2=AX2,AW2,""). Can any please help me how to write theb above formula in excel VBA. I have already copied this formula in VBA, but the output shows '1004' error,

I have already copied this formula in VBA, but the output shows '1004' error,

pavan sai
  • 11
  • 1
  • 1
    Please share your code so we can better understand what you are trying to do. Are you trying to write a formula or the result of the formula? Where will the result be located, e.g. `AV2` or `AV2:AVLastRow` or something else? An error is occurring. What is its description (there are many '1004-errors')? – VBasic2008 Dec 19 '22 at 15:04

1 Answers1

1

Use IIF() in VBA. Try-

Sub TestIIF()
    Debug.Print IIf(Range("AY2") = Range("AX2"), Range("AW2"), "")
End Sub
Harun24hr
  • 30,391
  • 4
  • 21
  • 36