Results 1 to 9 of 9

Thread: Userform-Listbox, Copying and Pasting form one workbook to another

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Userform-Listbox, Copying and Pasting form one workbook to another

    First time poster but have used the forum to help me many times. I couldn't find anything previously posted that fits my particular problem:

    I have a userform which brings up 2 list boxes. The list boxes show all open workbooks. Here is my code:

    [vba]Private Sub UserForm_Activate()
    'Populate list box with names of open workbooks.
    Dim wb As Workbook
    For Each wb In Workbooks
    ListBox1.AddItem wb.Name
    ListBox2.AddItem wb.Name
    Next wb
    End Sub[/vba]
    I want to add a button to my userform which will call a macro which does the following:

    1) Copies the following range from the Listbox1 selection workbook:

    'The worksheet name is "Sales Details"
    Range("A9").Select
    Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

    2) Pastes that selection (with formatting) to the end of the Listbox2 selection workbook:

    'The worksheet name is also "Sales Details"
    The pasted values should start in the first row with no value in Column A (i achieve this by
    selecting "A9", ctrl+down

    Also, is there a way to select multiple workbooks in Listbox1 and paste the selections in each of those workbooks to the end of the Listbox2 selected workbook.

    I'm not even sure if this is possible. Anyone have any ideas?

    Thanks,

    Brian
    Last edited by Aussiebear; 03-08-2011 at 05:52 PM. Reason: added VBA Tags to code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •