+ Reply to Thread
Results 1 to 5 of 5

Creating a new excel workbook - newbie help!

  1. #1
    Registered User
    Join Date
    03-30-2014
    Location
    Lancashire
    MS-Off Ver
    Excel 2003
    Posts
    5

    Creating a new excel workbook - newbie help!

    Hi All

    Hope someone can help. Am sure this is probably simple for those in the know
    Bear in mind my knowledge is basic to say the least!

    I have a workbook - lets call it workbook "X" and within workbook X I have 8 worksheets.

    I would like to have a command button on a worksheet in workbook X, which when I press it, copies worksheets 2,3, 4 and 5 only into a new workbook called workbook Y.

    I managed to create the command button and then by playing around and using:

    Private Sub CommandButton1_Click()
    Sheets("2").Copy
    End Sub

    I managed to create a workbook with 1 sheet in but have no clue how to add the other sheets in and to save it as workbook Y.

    Any help gratefully received!!!

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Creating a new excel workbook - newbie help!

    This should be really easy.

    This can be done quite easily by using the macro recorder.

    I just recorded this for you.

    The only changes I made were:

    A: simplified the save as line to remove the directory address
    B: I indented the lines where you select the sheet to move.

    eg
    Please Login or Register  to view this content.
    This stops that line working,
    I thought that the line was superflous and I commented it out to check.
    It still works so those lines can be deleted.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-31-2014 at 08:03 AM.

  3. #3
    Registered User
    Join Date
    03-30-2014
    Location
    Lancashire
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Creating a new excel workbook - newbie help!

    Fabulous - I shall try this now

  4. #4
    Registered User
    Join Date
    03-30-2014
    Location
    Lancashire
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Creating a new excel workbook - newbie help!

    Ok - sorry if this is a silly question but do I simply copy the code above between the following two lines?

    Private Sub CommandButton8_Click()

    End Sub

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Creating a new excel workbook - newbie help!

    you can assign the macro to the command button or insert the code as you propose.

    to assign the macro, select developer, then click on design mode,
    now right click on your button and select assign macro,

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 8
    Last Post: 07-05-2013, 11:23 PM
  2. Replies: 2
    Last Post: 08-28-2012, 05:55 AM
  3. Replies: 4
    Last Post: 06-13-2012, 01:34 AM
  4. Creating an Instance of Excel using VBS to run a VBA Workbook
    By DumbLittlePunk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2011, 11:01 AM
  5. Creating a workbook using Excel and VBA
    By cugine1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2008, 02:49 PM

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