如何插入双引号或单引号 [英] How to Insert Double or Single Quotes

查看:246
本文介绍了如何插入双引号或单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个长名单列表,我需要引号(它可以是双引号或单引号),我有约8000个。我有他们在Excel中没有任何报价,我可以复制所有的名称和粘贴他们没有问题,但仍然没有报价。我看了看,并寻找一个Excel公式来添加引号到每一行的名称,但我没有运气。我也试过一些聪明的查找和替换技术,但没有工作过。我要查找的格式是:



Allen或Allen



工作。我需要这个,所以我可以存储信息到数据库。任何帮助是极大的赞赏。感谢



[b] PS:[/ b]



我发现其他人在线需要同样的事我需要做,这个解决方案为他们工作,但我不知道该怎么做:


您可以使用范围
变量(例如myCell)然后
使用它来迭代范围对象的选择
集合,像这样




Sub AddQuote()
Dim myCell As Range
对于每个myCell在选择中
如果myCell.Value< > then
myCell.Value = Chr(34)& myCell.Value
结束如果
下一个myCell
结束子

另一个也为其他人工作的解决方案是:

  Sub OneUglyExport()

Dim FileToSave,c As范围,OneBigOleString作为字符串

FileToSave = Application.GetSaveAsFilename

打开FileToSave输出作为#1

对于每个c在选择

如果Len(c.Text)<> 0 Then _

OneBigOleString = OneBigOleString& ,& Chr(34)& Trim(c.Text)& Chr(34)

下一页

打印#1,Mid(OneBigOleString,3,Len(OneBigOleString))

关闭#1

End Sub


解决方案

非引号的值




  • 列A包含名称。

  • 将以下公式放入列B
    =& A1&

  • 复制列B并粘贴特殊 - >值



使用自定义函数



 公共函数Enquote(单元格作为范围,可选引用字符串作为字符串=作为变式
Enquote = quoteCharacter& cell.value& quoteCharacter
End Function

= OfficePersonal.xls!Enquote )



= OfficePersonal.xls!Enquote(A1,')



要获取永久引用的字符串,您必须复制公式值和粘贴特殊值。


I have a long list of names that I need to have quotes around (it can be double or single quotes) and I have about 8,000 of them. I have them in Excel without any quotes and I can copy all of the names and paste them no problem but there are still no quotes. I have looked and looked for an Excel formula to add quotes to the name in each row but I have had no luck. I have also tried some clever find and replace techniques but no have worked either. The format I am looking for is this:

"Allen" or 'Allen'

Any of those would work. I need this so I can store the info into a database. Any help is greatly appreciated. Thanks

[b]PS:[/b]

I have found other people online needing the same thing done that I need done and this solution has worked for them but I do not know what do with it:

You can fix it by using a range variable (myCell for example) and then use that to iterate the 'selection' collection of range objects, like so

Sub AddQuote()
Dim myCell As Range
    For Each myCell In Selection
        If myCell.Value <> "" Then
            myCell.Value = Chr(34) & myCell.Value
        End If
    Next myCell
End Sub

Another solution that also worked for others was:

Sub OneUglyExport()

Dim FileToSave, c As Range, OneBigOleString As String

FileToSave = Application.GetSaveAsFilename

Open FileToSave For Output As #1

For Each c In Selection

If Len(c.Text) <> 0 Then _

    OneBigOleString = OneBigOleString & ", " & Chr(34) & Trim(c.Text) & Chr(34)

Next

Print #1, Mid(OneBigOleString, 3, Len(OneBigOleString))

Close #1

End Sub

解决方案

To Create New Quoted Values from Unquoted Values

  • Column A contains the names.
  • Put the following formula into Column B = """" & A1 & """"
  • Copy Column B and Paste Special -> Values

Using a Custom Function

Public Function Enquote(cell As Range, Optional quoteCharacter As String = """") As Variant
    Enquote = quoteCharacter & cell.value & quoteCharacter
End Function

=OfficePersonal.xls!Enquote(A1)

=OfficePersonal.xls!Enquote(A1, "'")

To get permanent quoted strings, you will have to copy formula values and paste-special-values.

这篇关于如何插入双引号或单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆