0

I get this code in this forum, but I don't know how to give condition example if "A16" is not empty than "B16" can show either "YES" or "NO". If "A16" is empty, than nothing to show?

Sub OddRowAlert()
With Range("B16:B100")  
.Formula = "=IF((MOD(ROW(B16),2)),"YES","NO")"  
.Formula = .Value
End With
End Sub
xdenama
  • 19
  • 5
  • So you asked a question that was closed as duplicate, and immediately opened a new one with exactly the same text? Wow. Btw: SO is *not* a forum. – FunThomas Jul 14 '20 at 07:41
  • Does this answer your question? [How do I put double quotes in a string in vba?](https://stackoverflow.com/questions/9024724/how-do-i-put-double-quotes-in-a-string-in-vba) – FunThomas Jul 14 '20 at 07:42

1 Answers1

0
.Formula = "=IF(A16="""","""",IF((MOD(ROW(B16),2)),""YES"",""NO""))"
BDra
  • 426
  • 4
  • 12
  • It's not produce "YES" or "NO", it's just show "FALSE" even if "A16" is empty or not. – xdenama Jul 14 '20 at 06:21
  • Sorry, quotation marks need to be doubled in the VBA in order to produce single quotation marks in the output. I have corrected the answer. – BDra Jul 14 '20 at 06:46
  • If you don't mind, one more question... Let say, now, ignore the odd and even. I want duplicate same statement every 3 row. Example, I want repeat "2017" for first row, "2018" second row, "2019" third row, and repeat "2017" for fourth row, "2018" for fifth row and so on... – xdenama Jul 14 '20 at 07:40
  • Please limit your questions to one per topic. – braX Jul 14 '20 at 07:43