卡住。我需要一些 VBA 代码来在 excel 范围内的每个单元格中的字符串周围插入双引号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2852921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:27:16 来源:igfitidea点击:
Stuck. I need some VBA code to insert double-quotes around strings in each cell in an excel range
提问by cmm
I'm familiar with VB.NET, but VBA in excel has me stumped. With my best attempt, I get a "Type mismatch" error:
我熟悉 VB.NET,但 excel 中的 VBA 让我很难过。尽我最大的努力,我收到了“类型不匹配”错误:
Sub AddQuotes()
For Each x In Range("List").Cells
x.Text = "*" * " & x.text & " & "*"
Next
End Sub
回答by Tom Womack
Try using chr(34) for the double-quote character
尝试使用 chr(34) 作为双引号字符
eg chr(34) & x.text & chr(34)
例如 chr(34) & x.text & chr(34)

