Thread: vba error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default vba error

Hi
you can't use the copy method on string variables. Allowed are only
objects (as range or worksheet objects)

--
Regards
Frank Kabel
Frankfurt, Germany


Tom wrote:
Please help, I need this code to work.

The msgbox is fine but I need it on paer and in other
cells but it will not copy

Only the copy command fails, the other code works ok.


Sub Macro1()

'cell c6 contains the text "This bit"
myvar = Range("C6").Text
Selection.Copy
mytext = myvar & " Works " & Trim$(215) & " days each year"
MsgBox mytext

' I want to copy the string mytext into clipboard
mytext.Copy
' but that command fails

Range("D15").Select
ActiveSheet.Paste

End Sub