+ Reply to Thread
Results 1 to 5 of 5

Auto Workbook open by sheet number not name.

  1. #1
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Auto Workbook open by sheet number not name.

    Hi guys

    I have the following Macro
    Please Login or Register  to view this content.
    However, How do I change this to work only on 3 specific sheets as number E.G

    Sub Selectsheet()
    Worksheets(1).Activate

    End Sub
    As there are about 16 sheets, and only 4 of them this code will be used on.
    Conditional formatting is out of the question, as alot of dragging and dropping is used which removes it.
    Can not give an actual sheet name, as these change every week, but they will always be on the same sheet numbers E.G Sheets 1,2,3,4

    The ranges on this look small, as i'm only playing around at the moment to test what does what.

    Thanks.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Auto Workbook open by sheet number not name.

    try looping through the worksheets

    Please Login or Register  to view this content.
    Last edited by Sean Thomas; 01-19-2014 at 07:37 AM. Reason: error
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Re: Auto Workbook open by sheet number not name.

    Thanks

    Luckily the sheets in question are sheet 13,14,15,16 so are in order, so i'll cahnge it to 13 to 16, I'll try it out in a couple of hours, and let you know how i got on!

    Thanks alot.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Auto Workbook open by sheet number not name.

    The problem with what you are doing is if you don't know the sheet names or sheet index it gets difficult.
    If you don't know the above, then if there is something in common on each of the sheets then you can use an if statement


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Re: Auto Workbook open by sheet number not name.

    I've tried the first one you've posted on my tset workbook, and it's working fine

    The tab names are actually dates and we have 4 weeks worth. but the ones that I want to run on are always going to be sheets 13,15,15,16 so i think it will be just fine.

    I was thinking of only doing the current weeks tab by having a a formula on a spare sheet, which would show the date of the tab I want, then have a macro look at what that cell value is and then find the tab with the same value. but no need now.


    Many Thanks.

+ 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. Auto open a sheet on certain conditions and copying a template to new sheet
    By gm2612 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-24-2013, 12:04 AM
  2. Replies: 0
    Last Post: 01-07-2013, 01:22 PM
  3. auto create worksheet on workbook open and give each sheet A1 specific header
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-11-2011, 03:52 PM
  4. auto run macro when open workbook
    By kaffal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2009, 02:58 AM
  5. Replies: 0
    Last Post: 03-06-2006, 01:07 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