+ Reply to Thread
Results 1 to 7 of 7

VBA Adding and Deleting Sheets according to a list

  1. #1
    Registered User
    Join Date
    10-20-2013
    Location
    Ios, Greece
    MS-Off Ver
    Excel 2007
    Posts
    2

    VBA Adding and Deleting Sheets according to a list

    The question is the following:

    A worksheet named AllCars list all the car brands available in a dealer in the column A (starts from cell A2).
    (1) For each car in the list, it checks whether there is a worksheet with the name of that car in the workbook, and if there isn’t one, it adds one; and (2) it deletes any car worksheet if the worksheet’s name is not in the current AllCars list. (Warning: The sub should also work if the AllCars list contains exactly one car brand or no car brands at all).

    for example:

    Cell A2: Toyota
    A3: Ferrari
    A4: Audi
    A5: Mercedes
    A6: Acura
    A7: Lexus



    And what I have right now is:

    Please Login or Register  to view this content.

    but it is nowhere near working. It adds many cells at the end, but without the car names


    Many thanks in advance for your help. Any help would be very appreciated!

  2. #2
    Registered User
    Join Date
    10-20-2013
    Location
    Ios, Greece
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA Adding and Deleting Sheets according to a list

    Okay I have done it thanks!!!

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: VBA Adding and Deleting Sheets according to a list

    Hi, miconmicon,

    fine if you have figured it out by yourself - you should post the solution for others users who might have the same problem and mark the thread Solved via Thread Tools over the first post.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    12-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA Adding and Deleting Sheets according to a list

    I'm having the exact same problem.. i managed to add Sheets that are currently on my list, but i cannot delete the sheets that are no longer on my list.
    this is the code i have so far to add new sheets.

    I have a list of cities like
    Denver
    Colorado
    San Diego
    etc..

    Please Login or Register  to view this content.
    Thanks!
    Last edited by bmtomahawk3; 12-01-2013 at 04:41 AM.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: VBA Adding and Deleting Sheets according to a list

    Hi, bmtomahawk3,

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.


    You have to add code-tags when showing your procedure here on Excel-Forum according to Forum Rule #3.

    The data begins on Range A2, you would need to change this to suit your needs:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    12-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA Adding and Deleting Sheets according to a list

    Thanks for your post Holgar! it works.. and i have read the rules and thanks for pointing it out.. will follow it in future

    By the way, what does "If not Evaluate" and "ISREF" mean?
    sorry hope you can bear with me.. newbie here

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: VBA Adding and Deleting Sheets according to a list

    Hi, bmtomahawk3,

    Evaluate is used for working with WorksheetFunctions in VBA. ISREF is trying to build a connection to the Sheet given before the exclamation mark and Range A1 on that very sheet - if not available the sheet is not included in the workbook and should be added.

    Ciao,
    Holger

+ 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. Adding and deleting to a list from two different workbooks.
    By emilyloz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2013, 10:29 AM
  2. Adding and deleting to a list from two different workbooks. I NEED HELP!!!!!!
    By emilyloz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-11-2013, 08:20 AM
  3. Replicated adding/deleting rows on seperate sheets
    By hlep in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-23-2012, 05:41 AM
  4. Replies: 1
    Last Post: 05-21-2012, 03:00 AM
  5. [SOLVED] Adding And Deleting Sheets
    By Anice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2006, 10:55 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