VBA copy button to copy text from textbox

I need to create a copy button to copy the text i previously inserted in a textbox, all this in excell

Upvotes: 1

Views: 19446

Answers (1)

Oneide
Oneide

Reputation: 1020

Consider you have a TextBox named TextBox1 and a CommandButton named CommandButton1:

Private Sub CommandButton1_Click()
    Dim MyData As New DataObject
    MyData.SetText TextBox1.Text
    MyData.PutInClipboard
End Sub

After clicking CommandButton1, the text on TextBox1 is ready to be pasted in any proper place.

Upvotes: 8

Related Questions