Home » excel » excel – VBA converting formula to comment

excel – VBA converting formula to comment

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a formula that uses an apostrophe “‘” and therefore VBA reads it as a comment, is there anyway to prevent this?

formula is

=SUMPRODUCT(SUMIF(INDIRECT("'"&$A$1:$A$10&"'!"&"$BI$1:$BI$1000"),C4,INDIRECT("'"&$A$1:$A$10&"'!"&"$ax$1:$ax$1000")))

have everything else working

How to&Answers:

Just use Chr(34) in VBA and CHAR(34) in workbook formulas in place of ". Much more easier to use and not so hard to understand if it’s the first time you see it.

my_quoted_string = "this part is not in quotes " & Chr(34) & "while this part is" & Chr(34)

Will return

this part is not in quotes "while this part is"

For apostrophes use Chr(39) and CHAR(39) instead.