Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Quotes in String

Status
Not open for further replies.

ThomasLafferty

Instructor
Mar 14, 2005
549
US
Hi!
I'm using VBA to write a formula to a cell via range. The formula string must be enclosed in double quotes, however the formula itself is examining text values which must be enclosed in quotes. Doing this causes VBA to treat the first quote of the text values as being the end of the statement. How should I do this?


Code:
Range("T12").FormulaR1C1 = "=IF(OR(LEFT(H12,2)="HD",LEFT(H12,2)="CL"," _
    & "LEFT(H12,3)=''THD'',H12=0),0,HLOOKUP(S12,PricingTable,T12,FALSE))"

Thanks!
Tom

Born once die twice; born twice die once.
 
For putting quotes into a worksheet, ie a formula, where you want a quote to physically appear, use double quotes ...

Code:
Range("T12").Formula = "=IF(OR(LEFT(H12,2)=""HD"",LEFT(H12,2)=""CL"",LEFT(H12,3)=''THD'',H12=0),0,HLOOKUP(S12,PricingTable,T12,FALSE))"

HTH

Regards,
Zack Barresse

Simplicity is the ultimate sophistication. What is a MS MVP? PODA
- Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top