0

Selection.FormulaR1C1 = "=IF(RC[-1-" & NofRanks & "]>R4C3,RC[-4-" & NofRanks & "]/R2C3,0)"

I don't understand why it's giving me a syntax error. Can someone please help?

Here NofRanks is a variable-integer.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
  • I believe the problem is the quotes around the comma (`","`) what happens if you remove them? – cybernetic.nomad Nov 26 '21 at 15:35
  • 1
    Try `"=VLOOKUP(RC1,'Basic Sheet'!C" & j & ":C6, 6,FALSE)"` – Raymond Wu Nov 26 '21 at 15:41
  • @RaymondWu Thank you, i wasted 6 hours working on this, should have had the brains to ask in the 1st place, i was running around in circles!!! – Mystical Devices Nov 26 '21 at 15:46
  • Selection.FormulaR1C1 = "=VLOOKUP(RC1,'Basic Sheet'!C" & j & ":C"&j+5&", 6,FALSE)" if i try this, why am i getting error again? what mistake am i making? – Mystical Devices Nov 26 '21 at 15:49
  • If you have trouble translating formula to vba, what you can do it make `Debug.Print` the string that you make and copy-paste the output in the immediate window to the cell formula bar and see if it works. Sometimes you might not even need to copy-paste as looking at the output will make you realise what are you passing to the `Formula` property. @MysticalDevices – Raymond Wu Nov 26 '21 at 15:58
  • Make sure you have space inbetween the variable, operator and strings. The lack of space might cause VBA to read it differently. @MysticalDevices – Raymond Wu Nov 26 '21 at 16:03

0 Answers0