Muhammad Haroon
Muhammad Haroon

Reputation: 284

Excel formula containing double quotes through VBA

Range("D2").Formula = "=IF(C2>0,HYPERLINK(\\\Haroon-pc\d\DatabaseCNIC\"&C2&".png",C2),"")"

my excel formula has ampersand, slashes. quotes etc. How to set Range("D2").Formula" with above formula.

Please someone write it for me in proper format.

Upvotes: 3

Views: 93

Answers (1)

Gary's Student
Gary's Student

Reputation: 96791

Consider:

Sub qwerty()
   Range("D2").Formula = "=IF(C2>0,HYPERLINK(""\\\Haroon-pc\d\DatabaseCNIC\.png"",C2),"""")"
End Sub

Upvotes: 3

Related Questions