从MULTIPLE单元格复制时不要使用引号

时间:2016-10-11 07:55:02

标签: excel vba excel-vba

关于使用CopyCellContents()从单元格复制时退出引号有一个很好的答案,但是这只适用于每个单元格,如何调整它以适用于更大的单元格选择?

    Sub CopyCellContents()
    'create a reference in the VBE to Microsft Forms 2.0 Lib
    ' do this by (in VBA editor) clicking tools - > references and then ticking "Microsoft Forms 2.0 Library"                  
    Dim objData As New DataObject
    Dim strTemp As String
    strTemp = Replace(ActiveCell.Value, Chr(10), vbCrLf)
    objData.SetText (strTemp)
    objData.PutInClipboard
    End Sub

我找到了一些关于这个主题的代码,但不确定如何调整它,请告知:

    Dim oneCell As Range
    For Each oneCell In Selection
    oneCell.Value = Application.Substitute(Application.Substitute(CStr(oneCell.Value), vbLf, vbCr), vbCr, "-")
    Next oneCell

0 个答案:

没有答案