Excel error: expected end of statement, what does this mean?

I am trying to write this formula into a cell via my script:

  strFormulas(1) = "=IF(AND(I2<12.2,I2>=8.2),"t","f")"

And it keeps coming up as an error, even though it works just fine in the actual sheet if I manually input it into the cell. What is it expecting me to do here?


You need to escape quotes. Try this:

strFormulas(1) = "=IF(AND(I2<12.2,I2>=8.2),""t"",""f"")"

The issue that you are running into is that " is interpreted as beginning or ending a VBA string. So VBA parses your expression as

strFormulas(1) = "=IF(AND(I2<12.2,I2>=8.2),"

with "garbage" at the end. This "garbage" is what it is complaining about. If you need to include a " within a VBA string, use "".

Need Your Help

How to launch my Android / IOS app from a link

android ios url cordova phonegap-build

I have made android/IOS application using PHONEGAP BUILD its working fine for mi. Now i want to open that Application through link. So that I can provide this link to customers through mail and mes...

:nth-last-child to select second half of list of arbitrary length

html css css3 css-selectors

Given an list of arbitrary length, how do I select the second half of the list items?