Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. pasting from text document into excel comments
  2. Dim myClip As New DataObject
  3. Dim myString As String
  4.  
  5. myClip.GetFromClipboard
  6.  
  7. myString = myClip.GetText
  8. Sheet1.Range("A1").AddComment myString
  9.        
  10. Sub AddCommentsToSelection()
  11.  
  12. Dim myClip As New DataObject
  13. Dim myString As String
  14. Dim c As Range, arr, x As Integer
  15.  
  16.     myClip.GetFromClipboard
  17.     myString = myClip.GetText
  18.     If Len(myString) = 0 Then Exit Sub
  19.  
  20.     Set c = Selection.Cells(1)
  21.  
  22.     arr = Split(myString, vbCrLf)
  23.     For x = LBound(arr) To UBound(arr)
  24.         c.AddComment arr(x)
  25.         Set c = c.Offset(1, 0)
  26.     Next x
  27.  
  28. End Sub