Question : Copy Excel Cell, but without "tab" or "crlf"

Hi,

  if would like to copy the contents of a Cell from an excel spreadsheet,
  then paste it to another application.
  the problem is that the other application will get the "cell delimiter" also, so a tab or crlf character at the end.
  so I have each time to delete that character from the textbox before I can continue there...
  hundreds of times which is time-consuming.

  is there an option in excel to change the copy/paste behaviour when copying single cells?

thanks in advance

Answer : Copy Excel Cell, but without "tab" or "crlf"

There is no option to do this. You will need a macro:

Public Sub CopyCellsAsText()

' Copy the selection as text so that it can be pasted into another instance of
' Excel. This routine is required if any of the source cells contain more then
' 255 characters of text. Requires a reference to the Microsoft Forms 2.0 Object
' Library.

   Dim Clipboard As DataObject ' Requires reference to Microsoft Forms 2.0 Library
   Dim Row As Long
   Dim Column As Long
   Dim Text As String
   
   Set Clipboard = New DataObject
   
   With Selection
      For Row = 1 To .Rows.Count
         For Column = 1 To .Columns.Count
            If Column > 1 Then Text = Text & ", "
            Text = Text & .Cells(Row, Column)
         Next Column
         Text = Text & ", "
      Next Row
   End With
   Text = Left(Text, Len(Text) - 2)
   
   Clipboard.SetText Text
   Clipboard.PutInClipboard

End Sub

Inlcude a reference to Microsoft Forms 2.0 Object Library.

Kevin
Random Solutions  
 
programming4us programming4us