+ Reply to Thread
Results 1 to 18 of 18

Is it possible to make this code run on multiple sheets?

  1. #1
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Is it possible to make this code run on multiple sheets?

    Here is a link to my original post:- http://www.excelforum.com/showthread.php?t=1169539

    Although the above post solved my initial problem I soon realized that I had to change my workbook layout in order to make it manageable and easier to use.
    Where as the previous version had 1 sheet/tab for all staff I had to change it so I now have a number of tabs across the bottom which relates to the first letter of a persons surname

    Example:
    All staff with the surname beginning with A are placed in the tab labeled "A"
    All staff with the surname beginning with B are placed in the tab labeled "B" and so on....

    What I want to know is, is it possible to change the code given to me previously in order for it to work on all pages as at the moment it only works on tab A.
    I have tried simply copying the code into tab B and changing the variables at the top and as far as I can tell it hasnt worked unless i've done something wrong.

    Code being used in tab A.

    Please Login or Register  to view this content.
    Up to date copy of a slimmed down version of the workbook below.
    Attached Files Attached Files
    Last edited by maco20; 01-18-2017 at 02:54 PM.

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Is it possible to make this code run on multiple sheets?

    How is this code triggered ?
    Is there a button ? Or event?
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  3. #3
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    Sorry I forgot to mention that. Its currently triggered using Ctrl + x

  4. #4
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Is it possible to make this code run on multiple sheets?

    Actually this is your problem. Both of the codes in your sample file gets triggered using Ctr+X. You should find another triggering event or change the combination for each code. (every code works fine )

  5. #5
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    Would it be possible to make the code run on every page using 1 trigger??

  6. #6
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Is it possible to make this code run on multiple sheets?

    Can you please give me some name examples?
    is it Name Surname - goes to sheet S ?
    or is it Surname Name?
    I'm trying to set the N something like
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    It's Surname Name goes to sheet S

    Example
    Smith John will got to sheet S

  8. #8
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Is it possible to make this code run on multiple sheets?

    perfect! my code should work fine:

    make this replacements:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    Sorry for sounding dumb but does the code stay in sheet A? as I have made the changes you mentioned but now nothing is happening.

    Also does the below variable stay or go?

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Is it possible to make this code run on multiple sheets?

    I have tried the code and it works fine (there was a short error cause in Shorts and Overs tabs use to be 'Thur' and in the alphabet tabs just THU)

    I'm uploading your file with the modifications.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    Thanks for your help your copy works.

    The only problem im getting now is that if the shorts and overs pages are blank and you accidentally run the code which I did it throws a error 400 up and the script no longer works at all.

  12. #12
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    Looking for a bit more help... The end is in sight I believe haha...

    Ive sorted the error 400 that I mentioned above however the problem I have is that when I change the date im getting another error which is

    "Object variable or With block variable not set."

    This is also happening in the sample file uploaded by bulina26 above.

    Any help to finish this would be greatly appreciated.

    Thanks

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Is it possible to make this code run on multiple sheets?

    Hi maco20

    Please attach the offending Workbook (YOUR Workbook that exhibits the error).
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  14. #14
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Is it possible to make this code run on multiple sheets?

    hi there!
    the problem is this line:
    Please Login or Register  to view this content.
    this line is looking to find the column to write in, searching for the weekday (Mon Tue etc..) in the N sheet just a row above which is good for the first date but wrong for the any other.
    So in order to correct it we will use the 8th row (the table header)

    You should replace myDateRow - 1 with 8

    Please Login or Register  to view this content.
    There are 4 replacements to be done (2 for the Shorts and 2 for the Overs)
    Please tell me if you find any other problem.
    (Sorry for keep you waiting)

  15. #15
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    Thats fantastic everything as far as I can tell from my tests today works exactly as it should.
    I didnt mind waiting as your help has and will save me plenty of time in the future.

    I would also like to thank jaslake who provided me with the initial code...

    Maco

  16. #16
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    It looks like I spoke to soon.

    The error 400 is back... If 1 or more names does not have any data on the "Shorts" page the error is displayed.
    If all names have at least 1 number next to it in the "Shorts" page then there is no problem and the error isnt shown.
    I have tried leaving one row blank but putting a number in the overs page but the error is still shown so it has to be something to do with the shorts page...

    Any ideas?
    Attached Files Attached Files

  17. #17
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Is it possible to make this code run on multiple sheets?

    yes, replace (2 replacements)
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    01-12-2017
    Location
    United Kingdom
    MS-Off Ver
    2007
    Posts
    29

    Re: Is it possible to make this code run on multiple sheets?

    Another one bites the dust :-)

+ 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. how to make code to copy VBA from some sheets to sheet total
    By thaimic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2016, 04:25 AM
  2. Make the same VBA code work for all sheets of the Workbook.
    By Francisco Sousa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2015, 07:35 AM
  3. How to make this code run in all sheets
    By geliedee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2014, 10:35 AM
  4. Replies: 1
    Last Post: 08-14-2013, 12:01 PM
  5. [SOLVED] VBA / CODE to COPY TO NEW SHEETS when i make them.
    By xwarlock10x in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2013, 08:43 PM
  6. How do I make Sheet Code available in all sheets
    By antonf in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-20-2009, 04:31 PM
  7. [SOLVED] Make Changes in Multiple Excel Sheets
    By Ahsan Yousaf in forum Excel General
    Replies: 4
    Last Post: 04-01-2006, 06:40 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