cmm
cmm

Reputation: 51

Stuck. I need some VBA code to insert double-quotes around strings in each cell in an excel range

I'm familiar with VB.NET, but VBA in excel has me stumped. With my best attempt, I get a "Type mismatch" error:

Sub AddQuotes()

    For Each x In Range("List").Cells
    x.Text = "*" * " & x.text & " & "*"
    Next

End Sub

Upvotes: 5

Views: 23183

Answers (1)

Tom Womack
Tom Womack

Reputation: 791

Try using chr(34) for the double-quote character

eg chr(34) & x.text & chr(34)

Upvotes: 12

Related Questions