+ Reply to Thread
Results 1 to 3 of 3

Macro - user selecting certain worksheets to copy

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    2

    Macro - user selecting certain worksheets to copy

    Hi all,

    I'm relatively new to VB programming (I usually use c++) and wondering if anyone can help me with the following problem:

    I have 2 workbooks, workbook1 and workbook2. I want to create a macro that copies certain worksheets from workbook1 into workbook2, which are specified by the user (should this be via checkboxes, drop down menu, or is there a better method?) and are different each time.

    For example on one occasion the user may select worksheet1, worksheet5 and worksheet12 to copy across whereas on another occasion they may select worksheet 4 and worksheet 7. After the user has selected the worksheets there should be a button that copies the selected worksheets into workbook 2.

    If anybody is able to help me with pieces of code or just general pointers it would be much appreciated.

    Thanks,

    cj

  2. #2
    Registered User
    Join Date
    09-01-2010
    Location
    SoCal
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro - user selecting certain worksheets to copy

    Hi CJ,

    I'm at the end of my day, and i'm kind of a 'brute force' coder, not very elegant. But here's my 2 cents:

    Checkboxes would work well. (From the ribbon, Developer, Insert, under Form Controls)
    Right click on check box, then click Format Control to put the answer into a cell. (it'll be TRUE or FALSE)
    Give that answer cell a Range Name (Formulas, Define Name)
    Repeat for the possible worksheets.

    I would then write a brute-force macro to test each range name for TRUE.
    If true, copy spreadsheet(X) to workbook 2 (you can record a macro to get the copy part of the code)
    Assign the macro to a button, you're done.

    You probably need more code info, but I'm out of time. look into "If" statements, they're very easy.

    Hopefully this will get you started?

    -Jim

  3. #3
    Registered User
    Join Date
    06-13-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro - user selecting certain worksheets to copy

    Thanks for the help Jim, I'll give that a try.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1