+ Reply to Thread
Results 1 to 5 of 5

VBA Select All But Four Sheets In Workbook

  1. #1
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    VBA Select All But Four Sheets In Workbook

    Hi, I wonder whether someone may be able to help me please.

    From a number of threads I've found, I've put together the following script to select all sheets within my workbook, except for four.


    Please Login or Register  to view this content.
    The script runs, but only selects the last, out of about twenty of the sheets, and I'm a little unsure why.

    I just wondered whether someone may be able to look at this please and let me know where I've gone wrong.

    Many thanks and kind regards

  2. #2
    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,197

    Re: VBA Select All But Four Sheets In Workbook

    Hi, hobbiton73,

    any Select you perform will only have one sheet to refer to, the last sheet you found. Maybe try it like this building an array and using that for selecting (although any Selection should be useless as action may be done withour this):
    Please Login or Register  to view this content.
    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

  3. #3
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Select All But Four Sheets In Workbook

    Hi @HaHoBe, thank you very much for taking the time to reply to my post and for the solution, which perfectly, and I was particularly interested about your comment on how the 'Select' function works.

    Because I'm relatively new to VB, may I ask if you could possibly insert some comments into the code, so I can learn from this.

    Many thanks and kind regards

  4. #4
    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,197

    Re: VBA Select All But Four Sheets In Workbook

    Hi, hobbiton73,

    I´m a bit out of time by now - so it´s sort of "Typos To Go":
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Select All But Four Sheets In Workbook

    Hi @HaHoBe, that's absolutely no problem at all, thank you very much for doing this.

    Kind Regards and all the best.

+ 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. Select Case within For loop not copying sheets to a new workbook
    By buttonmasher in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2013, 02:30 PM
  2. select external workbook and them merge all sheets in one
    By jmaocubo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2009, 09:49 AM
  3. Re: Select All Sheets in Workbook
    By bttreadwell in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2005, 05:25 PM
  4. Select the same cell in different sheets in the same workbook?
    By PEA in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-03-2005, 03:05 AM
  5. Using Addin to select sheets in Active Workbook
    By ackurv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2005, 04:28 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