0

I am trying to fill cell F2 with the following formula =LEFT(F1,FIND("-",F1)-2))

I tried using Range("F2").Formula = "=LEFT(F1,FIND("-",F1)-2))" but get an error and from reading around see I'm supposed to use InStr instead of FIND in VBA, but as it's not as simple as a direct replacement I can't get it to work. Can someone please walk me through what I'm supposed to do here?!

  • 1
    You've got an extra parens in the formula, and you need to double up the inner quotes. `"=LEFT(F1,FIND(""-"",F1)-2)"`. – BigBen Sep 01 '21 at 14:18
  • 1
    But do you want the formula or the actual value given by that formula? Why do you mention `InStr`? If you just want the value, try `Range("F2").Value = Trim(Split(Range("F1").Value, "-")(0))` – JvdV Sep 01 '21 at 14:19
  • Thanks both, these solutions both worked. – user16766172 Sep 01 '21 at 14:43

0 Answers0