locked
VBA for pasting from clipboard (from Excel, to Excel) RRS feed

  • Question

  • Hello,

    I request users to copy Columns A:AV in their entirety in "Workbook A".  I then created a command button for them to paste the data into a separate Excel workbook, "Workbook B", to help eliminate errors.  What I wish to do is once they copy Columns A:AV in Workbook A, that the first row from this selection not be pasted into "Workbook B" when they press the command button.

    In other words, I am asking for code that will capture the clipboard contents and remove the first row, prior to being pasted elsewhere.

    I know that the simple answer is to have users select the required cells for copying, but the objective is to automate so as to minimize errors.

    Thanks!

    • Moved by Reed KimbleMVP Sunday, July 1, 2012 4:48 PM vba (From:Visual Basic Language)
    Tuesday, June 26, 2012 7:31 PM

Answers

  • I guess repost to the linked forum. Or here.

    Armin

    • Marked as answer by R.Shaw Saturday, June 30, 2012 10:00 PM
    Saturday, June 30, 2012 9:48 PM

All replies

  • Hello R.Shaw,

    Hello,

    I request users to copy Columns A:AV in their entirety in "Workbook A".  I then created a command button for them to paste the data into a separate Excel workbook, "Workbook B", to help eliminate errors.  What I wish to do is once they copy Columns A:AV in Workbook A, that the first row from this selection not be pasted into "Workbook B" when they press the command button.

    In other words, I am asking for code that will capture the clipboard contents and remove the first row, prior to being pasted elsewhere.

    I know that the simple answer is to have users select the required cells for copying, but the objective is to automate so as to minimize errors.

    Thanks!

    Welcome, for vba question is avialible dedicated Forum see link below http://social.msdn.microsoft.com/Forums/it-IT/isvvba/threads

    Regards.


    • Proposed as answer by Armin Zingler Tuesday, June 26, 2012 11:29 PM
    Tuesday, June 26, 2012 7:45 PM
  • Why don't you just select the range you want in your code, rather than requiring the users to manually select some specific range? For example:

        Dim wsSource As Worksheet, wbOut As Workbook, wsOut As Worksheet, lastRow As Long
        Set wbOut = Workbooks.Add()
        Set wsOut = wbOut.Worksheets(1)
        Set wsSource = ThisWorkbook.Worksheets(1)
        lastRow = wsSource.UsedRange.Row + wsSource.UsedRange.Rows.Count - 1
        wsSource.Range("A2:AV" & lastRow).Copy
        wsOut.Paste
        Application.CutCopyMode = False


    jmh

    Tuesday, June 26, 2012 7:56 PM
  • Why don't you just select the range you want in your code, rather than requiring the users to manually select some specific range? For example:

        Dim wsSource As Worksheet, wbOut As Workbook, wsOut As Worksheet, lastRow As Long
        Set wbOut = Workbooks.Add()
        Set wsOut = wbOut.Worksheets(1)
        Set wsSource = ThisWorkbook.Worksheets(1)
        lastRow = wsSource.UsedRange.Row + wsSource.UsedRange.Rows.Count - 1
        wsSource.Range("A2:AV" & lastRow).Copy
        wsOut.Paste
        Application.CutCopyMode = False


    jmh

    Thanks for the prompt reply.  I placed your code inside the code for the command button, and it executes but not as I require.  Regardless, this is progress and I appreciate the help.

    What I need the code to do is take data that has been copied from another workbook all together, and paste all but that first row in the current workbook (which has this command button), starting in the second row.  What I would like to add as well is that I have no control over the workbook with the source data (that is being copied), as it is a monthly report generated elsewhere.  I can only use code in the file which is receiving the data.


    • Edited by R.Shaw Wednesday, June 27, 2012 5:11 PM
    Wednesday, June 27, 2012 3:18 PM
  • Can anyone offer a solution to my question?

    Saturday, June 30, 2012 3:49 PM
  • Can anyone offer a solution to my question?

    See Carmelo's reply. This is a VB.Net forum.

    Armin

    Saturday, June 30, 2012 4:30 PM
  • Sorry . . . did he mean to re-post to VB.Net?  Because I could not find this thread in that forum.

    Thank-you in advance for clarifying.

    Saturday, June 30, 2012 9:30 PM
  • I guess repost to the linked forum. Or here.

    Armin

    • Marked as answer by R.Shaw Saturday, June 30, 2012 10:00 PM
    Saturday, June 30, 2012 9:48 PM
  • Okay - clear now.  Thank-you.
    Saturday, June 30, 2012 10:00 PM