简体   繁体   中英

VBA converting formula to comment

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM