Free Microsoft Excel 2013 Quick Reference

UserForm TextBox Paste From Clipboard

I want to highlight text from, lets say Notepad, right click then select
copy from the shortcut menu (copy to the clip board). Then I want to go to
my UserForm, put my cursor in the TextBox right click and select Paste. But
when I put the cursor in the TextBox and right click the shortcut menu (Cut,
Copy, Paste) does not pop up.

Is there code that I can add to maybe the Private Sub TextBox1_DblClick to
enable the paste from the clipboard.

Post your answer or comment

comments powered by Disqus

I have been trying to work this problem out for ages but can't seem to find an answer.

this is what i have so far

Private Sub CommandButton3_Click()

Dim objData As DataObject
Dim strClipBoard As String
Set objData = New DataObject
'Clear clipboard
objData.SetText ""
'Put text from textBox into clipboard
strClipBoard = Me.TextBox1.Value
objData.SetText strClipBoard

'Get text from clipboard into a string variable
strClipBoard = ""
strClipBoard = objData.GetText

'activate window
AppActivate ("Untitled - Notepad")

= objData.GetText

End Sub
so when the button is clicked, textbox1 text is copied to the clip board, sets the focus to the notepad window and is then supposed to paste. what am i supposed to be having at the end? atm as you can see it is blank infront of '= objData.GetText'.

if i get rid of the appactivate and put textbox2.text infront of '= objData.GetText', then it pastes from the clipboard.

i want the contents from the clipboard to paste into the active window. any active window i say to be active.


I need to fill a textbox named: tbxUserN in a UserForm with data from a public declared array created in Module1, specifically from arrayUserData(0).

After some reading I believe this is the code to use>>> Me.Controls(tbxUserN) = arrayUserData(0)

My problem is I'm not certain where/how to place the code so that after data is in the array from proceedure in Module1,
and thenUserForm is shown, the textbox will fill with the data.

This textboxt is for information display as part of a Wizard I'm writing.

Thanks for any assistance or recommended reading.

Hi, i'm wondering is there a way (a macro or a program) to automatically paste content from clipboard as soon as it gets there to Excel 2007 workbook ? for example to column A, but not to overwrite existing data, just to add data at the end of column A(next empty cell)...i'm asking because i'm copying data from an online database, and i can't select multiple data at the same time..i need to do it one by one..and i constantly need to change windows from web browser to excel..browser - ctrl-c, click on excel workbook - crl-v, and click back to would be ideal that content is autopasted to excel as soon as i select Ctrl-c..

Again..sorry for my bad english, and thanks in advance for your help

Is it possible to paste from the clipboard object directly into a multi-field
MS Acess table, or alternatively into an array.

The data on the clipboard will be multi column and multi row data. The
tabel will have the same number of columns (fields).

I know there are other ways of performing this task, but this option is the
best for the circumstances.



Hello OzGrid Family,

I am very new to this forum and VBA. I would love your help. I would like to place data from a userform textbox into the first empty cell within the range B5:B30. When I think about it algorithmically, the steps I would like to do are:

1. Find the first empty cell in range B5:B30
2. Paste the string from a user form Textbox into that cell
3. Then exit that function

Any assistance or suggestions in how I can achieve this in VB coding?

Thanks in advance for your help.

Hey People,

Just want to now if it is possible to past from an ActiveCell to a TextBox created on a Userform in VBA?

If so can someone help me out with the code.

Much Appreciated.


This a new question that arised from my earlier posting in

I have the following working code below, but am having trouble finding coding examples to select specific cells from the selected row (that was found by selecting a ComboBox value)and update TextBoxes with those individual values after the UserForm has been initialized (the bold "GREEN" comment in the code below). I have been able to find plenty of references to update TextBox values to Cells, but that doesn't do me much good in this application since the User needs to verify the old data in these cells before updating them using the UserForm TextBoxes.

I was toying around with several different variations of code (none of which worked properly), so I left it out for clarity of my working code. I'll post up this non-working code as needed, because I really wanted a fresh answer...not what I was trying to do. The attached file should be sufficient to see what's going on, but if not please ask questions.

thanks, ~Dan

     'Add list entries to the combo boxes. The value of each
     'box matches the existing SR Information spreadsheet entries
    With Sheets("SR Information") 
        .Range("A2", .Cells(Rows.Count, "A").End(xlUp)).Name = "MyRange" 
    End With 
    SRnumber.RowSource = "MyRange" 
     ' Set initial values to TextBoxes -not needed, just for testing-
     '    NBdate.Text = "Test NBD SR Number"
     '    ApartNumber.Text = "Test AP SR Number"
     '    UPdetails.Text = "Test UD SR Number"
End Sub 
Private Sub SRnumber_Change() 
    Dim ServiceRequestNumber As String 
    Dim c As Range 
    Dim rngG As Range 
    Sheets("SR Information").Select 
    With Selection 
         'Find value in ComboBox, and select row
        ServiceRequestNumber = SRnumber.Value 
        For Each c In Intersect(ActiveSheet.UsedRange, Columns("a")) 
            If c = ServiceRequestNumber Then 
                If rngG Is Nothing Then Set rngG = c.EntireRow 
                Set rngG = Union(rngG, c.EntireRow) 
            End If 
        Next c 
        [B][COLOR="Red"] ' >Insert Code Here?<  Update other TextBoxes with information contained in specific cells on the
selected row[/COLOR][/B]
    End With 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines

I want to populate a textbox (output) on one userform with data from a textbox (target) on another userform.
The data in the textbox (target) is the result of calculations in the userform code and is not gathered from or saved to a cell.
I want the textbox (output) to be populated at "Userform intialize" event.

I have tried various other methods without any success.

Any help or even a firm "this cannot be done" would be appreciated.

Hello All,

Im currently trying to "Validate" a user form that Ive used before bu
had problems.

Its part of a Clocking-In process that measures time spent at work.
The users of the form are asked how many hours they worked.

At the moment the validation checks whether the Textbox contains
number or not (using IsNumeric) though there is nothing that stops a
entry of 38:30:00, or similar, which causes me plenty of headache
later on.

Is there any way I can validate the TextBox to ensure that numbers ar
entered in the format - 38.50 (TensUnits.TenthsHundreths)?

If it makes any difference, the Userform doesnt paste to the Workshee
until a button is pressed

Many thanks in advance,


~~ Message posted from
~~View and post usenet messages directly from

Dear Helpers,

I would like to paste the content of the clipboard to the body of an outlook email using VBA.
I have copied some text and graphs from EXCEL and now need to paste this info in.
I'm sorry if this isn't the correct place to post this question, but i'm desperate.

Help please


Hi All, I was hoping that someone may be able to help with the following problem... I want to populate the textboxes on a userform with information from a row by double clicking the row. I can get this to work fine without sheet protection but cannot find a way to do this with the sheet protected. Any help will be greatly appreciated. Thank you in anticipation;

regards Jay

Hi from Europe!

I am using VBA to paste a clipboard filled with figures and dates from a Web
page but the VBA is altering 7 March 2006 (07/03/06) to 3 July 2006
(03/07/2006). This only happens in VB code - when pasting manually the date
is pasted fine.

I have searched the newsgroups but the only solution seems to be to use
Excel 2002 which I don't have.

The date is always in the third column of the clipboard - is it possible to
interrogate the clipboard? Are there any other avenues to explore?

Thanks in advance


I have copied data onto my office clipboard in excel but I cannot then paste
it. I have selected a new cell and clicked on the paste all button and the
highlighted selection. Selecting paste from Edit or Ctrl+v pastes fine.

I am pasting into a cell from clipboard, however date values change their original format. Is it possible to paste everything as text ??

Here's my Macro code:
'Clear Current Data
    'Temporarily save clipboard data
    Dim obj As New DataObject
    Dim t As String
    t = obj.GetText
    ' PASTE 
    ActiveSheet.Cells(2, 1).Select
    Dim pasteToRange As Range
    Application.ScreenUpdating = False
    Set pasteToRange = ActiveWindow.Selection
    ActiveSheet.PasteSpecial Format:="Text"
    Application.ScreenUpdating = True

I am trying to copy a range as a picture from excel and paste that into a
picturebox on a form.

The code I am using to copy is

to paste the chart into a picturebox I first tried
Me.PictureBox1.Image = Clipboard.GetImage

That did not work and then I tried
Me.PictureBox1.Image =
DirectCast(Clipboard.GetDataObject().GetData(DataFormats.Bitmap, False),

that did not work either.

I can paste the bitmap into any other application like word, excel or
outlook. When I query clipboard.containsimage I get false.

Please help !!!!!

Hi all,

I'm new to the forum, and have a pretty basic question. I'm trying to get a macro to paste something from my clipboard into the "formula" window in the conditional formatting dialog box. I have a macro that *almost* works. I just don't know how to code the "paste" part of the macro. A pic of the code is attached...The highlighted line is all i need help with.


For reference, this is the window that I'm trying to populate...format window.PNG

Can someone give me a hand? Thanks!

Hello All-
I am just trying to copy the contents of a TextBox onto the clipboard so that the text can be pasted in a Word document or anywhere as just text.

My textbox is named:

Any ideas how to accomplish this?


I'm building a UserForm that has several TextBoxes to gather basic project information to fill in the header of a report...

The first TextBox is the Job #... I'm trying to implement code for an "Auto Fill" button (based on working VBA code from another workbook) that will fill the other TextBoxes in the UserForm...
The working VBA code from the other workbook does "Auto Fill" for Worksheet Ranges, not UserForm TextBoxes...

How should I reference the UserForm Textboxes in the code to specify their value?

Sample of experimental code, not working;

Workbooks("Template Generator.xls").Forms("ProjectInfo").Activate 
If TextBox("InptJobNum").Text = "" Then 
    MsgBox "Please Insert Job Number" 
    Exit Sub 
    Jnum = TextBox("InptJobNum") 'Specify Job Number
    Workbooks("Job Log.xls").Sheets("Job Log").Activate 
End If 
If WorksheetFunction.CountIf(Range("A2:A1000"), Jnum) = 0 Then 
    Workbooks("Template Generator.xls").Forms("ProjectInfo").Activate 
    MsgBox "Invalid Job Number, or cannot be located... Please correct and try again" 
    Exit Sub 
End If 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines


I'm working on an excel based tool which I've been doing a fair amount of vba for. Generally it's going well but I've hit a stumbling block. On one page where I want users to input data the paste option is disabled in the context menu (right click) and Ctrl-V isn't working. I can, however, paste from the clipboard dialogue. I'm expecting users to paste in data from another workbook.

It's very strange, and very annoying. At one point I thought it might be to do with a sub running on the sheet.activate event - but I've removed anything like this from the relevant sheet's code.

Has anybody come across this before, and any suggestions. The relevant sheet doesn't have any protection on it or anything.




I've tried to adapt Aaron Blood's method of sending the text from a textbox to the clipboard but the code falls over in the middle line, possibly because my textbox1 is from the drawing toolbar:

    Application.SendKeys ("^c~") 
    InputBox "clipboard", ,  Sheets("Sheet1").TextBox1.Text 
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
If anyone knows how to adapt the above code or knows another method any help is much appreciated. Aaron's avatar is good fun too! Thanks in advance, Upside


Anyone know of a way to insert rows (as much as is needed from data that comes from the clipboard) above data and then insert data from clipboard. The amount of new rows needed is different from one paste to another.


Hi Guru's

I would like to know if the following is possible, I've been trawling the forums using the search function, but I can seem to pin down an answer.

I have a workbook containing the daily holiday records in hours of staff members (names in col A starting at row 2), the first six months are on sheet 1, the second six months on sheet 2, with each column representing a date (dates in row 1 starting at column B).

What I would like to achieve is by employing a UserForm to populate my Textboxes with the dates and hours taken as holiday, so returning anything with a value greater than 0 also ignoring blank cells.

The staff member lookup i am currently using is a combobox from the names in column A. I can return to a textbox information from a range but i have been unable to only select the values greater than 0. I have also been unable to show the dates with values greater than 0

Hope you can suggest a solution


Good Morning all,

I have a question regarding "copying data entered in a userform to cells in worksheets." The case is following;

I have 2 userforms and the passage between those userforms are made with a next/back button, I ask some general information such as customer name, location etc.. and when user clicks at the end to the "nextbutton" I want all the data entered in the userform/textboxes to be written in defined cells

Private Sub Next1_Click()
If Customer.Text = "" Then
MsgBox "Please complete Customer Field"
Exit Sub
ElseIf Countrychoose.Text = "" Then
MsgBox "Please choose a Country from the list"
Exit Sub
ElseIf Contact.Text = "" Then
MsgBox "Please enter a Contact"
Exit Sub
ElseIf Dollar.Value = False Then
If Euro.Value = False Then
MsgBox "Please choose a Currency"
Exit Sub
ElseIf Output.Value = False Then
If Time.Value = False Then
MsgBox "Please choose a Constant"
ElseIf Application.Text = "" Then
Application.Text = "N/A"
End If
End If
End If
End Sub

Sub Copydata()
Sheets("Worksheet").Range("D13") = Customer_Info.Customer.Text
Sheets("Worksheet").Range("D17") = Contact.Text
Sheets("Worksheet").Range("D15") = Countrychoose.Text
Sheets("Worksheet").Range("D19") = Contact.Text
End Sub

I have Excel 2003. I often copy text from other applications and simply want
to paste into excel - not going thru wizards or text-to-columns options.
Sometimes when I paste it parses the data (for example, on commas, etc) among
several columns and sometimes it doesn't. I can't figure out how or what is
controlling this.

At the moment I'm trying to change it back to no-parse but can't figure out
how to do it. Up until now when I pasted it would put everything in the row
in one cell - then the next row in the cell below, etc -- just the way I want

Any suggestions??? -Thanks,

No luck finding an answer? You could always try Google.