Leave out quotes when copying from cell

后端 未结 13 1071
情话喂你
情话喂你 2020-12-01 04:16

Problem:
When copying a cell from Excel outside of the program, double-quotes are added automatically.

Details:
I\'m using

13条回答
  •  既然无缘
    2020-12-01 04:50

    If you want to select multiple cells and copy their values to the clipboard without all those annoying quotes the following code may be useful. This is an enhancement of the code given above from user3616725.

    Sub CopyCells()
     'Attach Microsoft Forms 2.0 Library: tools\references\Browse\FM20.DLL
     'Then set a keyboard shortcut to the CopyCells Macro (eg Crtl T)
     Dim objData As New DataObject
     Dim cell As Object
     Dim concat As String
     Dim cellValue As String
     CR = ""
      For Each cell In Selection
      If IsNumeric(cell.Value) Then
       cellValue = LTrim(Str(cell.Value))
      Else
       cellValue = cell.Value
      End If
      concat = concat + CR + cellValue
      CR = Chr(13)
     Next
     objData.SetText (concat)
     objData.PutInClipboard
    End Sub
    

提交回复
热议问题