• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How can I include character for inches in VBA/macro?

bufo0892

New Member
In this subroutine I would like to have the result appear as HP 19" CRT Monitor, but I cannot figure out how to make it work. It's easy to make it work if it's a 19-foot monitor, as this code does. How do I get VBA to display inches, instead?


Sub LongItemNameForAssets()

Select Case Range("C2").Text

Case "19"

Range("D2").Value = """HP 19" & "'" & " CRT Monitor"""

End Select

End Sub
 
Bufo0892

I normally include a line

inch = Chr(34)


and then can use the inch name where required, in your case


inch = Chr(34)

Range("D2").Value = "HP 19" & inch & " CRT Monitor"
 
Hui,

I really would have preferred to use the ' character, but your response will work & I appreciate it. Thanks a lot.
 
Hui,

Sorry, I misunderstood what the output would look like. This does exactly what I was after, so thanks again.


Being a VBA newbie, I have another question, but I'll post it under new topic.
 
Bufo0892

the Foot character ' is Chr(39)

the Inch character " is Chr(34)
 
Back
Top