+ Reply to Thread
Results 1 to 9 of 9

Listbox Linked to Workbook Tabs (2007)

  1. #1
    Registered User
    Join Date
    10-17-2008
    Location
    Philadelphia
    Posts
    8

    Listbox Linked to Workbook Tabs (2007)

    Hello,

    I hope I can explain what I am trying to accomplish properly. Many years ago (5+), I had this exact workbook setup, but am having a lot of difficulty remembering VB & Excel and making this again from scratch.

    I am looking to create an Excel Workbook. The workbook will contain numerous tabs, each tab will essentially be a template, and contain basic formulas.

    On tab 1(Sheet1), I would like to have a listbox. The individual items in the listbox, should have the same name of, and be linked to all tabs in the workbook.

    There will also be three buttons.

    Button1 - Generates the names in the listbox based on existing tabs within the workbook
    Button2 - Opens a new workbook, and copies over the selected tabs (AKA - creates a working copy of the workbook)
    Button3 - Clears the selection and resets the listbox.

    The number of tabs, and contents of tabs, within the workbook will be changing. So the listbox should know to look for all tabs, be it 5, or 50.

    The end result would allow someone, who knows nothing of Excel, to open this workbook, as a read-only file. Generate a list of available tabs, select the tabs they need, generate a new workbook containing these tabs, that they can then edit to suit their needs.

    In my line of work (and I am sure everyones) there is a huge problem with consistancy. This leads to a snowball effect of problems carrying over, and being copied from one project to the next. As I mentioned earler, I once already had this workbook setup, and it solved all our consistancy problems. I am hoping to do the same.

    If anyone has any information, can help with code, or point me in the right direction, it would be greatly appreciated.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    There's a userform that I posted sometime ago here that lists all the sheets in a workbook. It's dsigned for selecting sheets to print but could easily be adapted for what you need.

    http://www.excelforum.com/excel-prog...tton-only.html
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-17-2008
    Location
    Philadelphia
    Posts
    8
    Roy,

    The information provided in your zip file "sheetstoprint" was quite helpful.

    I can see a few aspects being reused, but have a question regarding a component, as well as figuring out the code for another one that doesn't quite exist.

    1) Can you please provide information, or explain what is happening in this section of code:

    Please Login or Register  to view this content.
    2) I will not be using the "cmbPrint" function. However, I'd like to have a button that instead of printing the selected sheets, it will generate a new workbook that only contains the selected sheets. Do you have any information that would be helpful for this task?

    Thank you!
    Last edited by sjpagano; 10-21-2008 at 09:21 AM. Reason: Added more detail to code

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Does this help

    Please Login or Register  to view this content.
    You might not want to include Chart sheets.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-17-2008
    Location
    Philadelphia
    Posts
    8
    Roy,

    I attached my current workbook.

    I used the second version of your posted code. Here's whats happening:

    When I click the button, it creates a new workbook. However, it only copies over one of the selected sheets.

    If my tabs are:

    "Start here, a, b, c, d, e, f, g"

    On "Start here", I bring up the listbox, I select say, "A, B, C", then hit the button, "cmdGenerate" (button we're working on). That does the following:

    Creates a new workbook, names the workbook the name of the directory that the VB project/excel template exists in, appends the letter, "A" to the end of the name (I assume it's appending the name of the sheet), and only copies over sheet "a", and ignores B, and C.

    Any ideas?

    We work with project numbers. Would it be possible to have a text box somewhere where a person could input a 4-5 digit code, click the cmdGenerate button, and have it name the file along the lines of:

    #### - Schedules.xls (where #### is the number provided by the user)

    Thanks again!
    Attached Files Attached Files

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Use this amended code. The error was because the new workbook wasn't being closed, so the code now closes it but also will only work in the workbook that contains the form

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-17-2008
    Location
    Philadelphia
    Posts
    8
    Roy,

    It is creating multiple workbooks.

    Meaning, if I select "A,B,C". It creates three new workbooks, and closes each one. I'd rather have it not close anything if possible


    I'd like to see it place all selected sheets into a single workbook, and leave everything open.

    Also, what about the ability to manually name/save the workbook? People will be using this template off of a network drive, and saving their "new" workbook, to a specific location (based on project number). If at all possible, I'd like to have it do the following once the cmbGenerate button is clicked:

    - Close the listbox (same as clicking cancle), more or less returning the template with the VB code to it's original state.
    - Generate the new workbook with sheets
    - Prompt a Save-As on the new sheet, and have the name already specified, but require the user to specify a location. The name should be in the format I mentioned earlier (possibly using that method mentioned earlier) - "#### - Schedule.xls".

    Having it automatically save down to the users computer will lead to confusion among the less computer saavy here. "Where did it go? How can I find it? Is it on the network...wawawa"

    You've been extremely helpful, thanks again.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I thought that you wanted a separate workbook, reading back I see that you need to select pages & create a workbook containing them. Try this
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-17-2008
    Location
    Philadelphia
    Posts
    8
    Works like a champ. There are a few custom issues I think I need to attend to, but this has definatly put me on the right track.

    Thanks again!

+ 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: 3
    Last Post: 07-12-2014, 06:04 AM
  2. VLookup across multiple workbook tabs
    By andy838 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-05-2007, 04:43 PM
  3. Tabs List in a Workbook
    By vjboaz in forum Excel General
    Replies: 1
    Last Post: 09-26-2007, 10:25 AM
  4. Delete rows from another workbook
    By psatkar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2006, 05:28 AM
  5. Opening Multiple Linked Sheets
    By CPGUY33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2006, 11:31 AM

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