Results 1 to 10 of 10

Thread: setting loop code to check all named sheets

  1. #1
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    11

    setting loop code to check all named sheets

    Hi

    Code anybody help me to loop through the sheets.

    at the moment the code will look at ppe sheet and check the dates if any due date are found it generates an email and inserts a table in it.
    i am trying to have it check the other sheets in the work book forltruck, gas etc so that it would generate other emails with that sheet table in it
    hopfully changing the subject line i.e gas insections due, ppe instection due etc.


    Thank you for any assistance in advance

    Peter
    Attached Files Attached Files

  2. #2
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    13
    Instead of selecting PPE, why not do a loop.

    Code:
    Dim w as Worksheet
    For each w in Worksheets
    
    .......code.......
    
    next w

  3. #3
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    11
    hi

    do i just need to add this at the begining of my existing code removing the select ppe row and the next w at the end or
    do i need new code as well
    i am just trying to get my head around this coding lark :-)

    Peter

  4. #4
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    13
    do i just need to add this at the begining of my existing code removing the select ppe row and the next w at the end
    Yes.

    Here is a link on this concept.

    Macro to Loop Through All Worksheets in a Workbook

  5. #5
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    11
    Hi Alan

    I have tried every which way to try and get this thing to do what i want but keep screwing it up (i must be thick as it is probably very simple)
    the attached selects the ppe sheet and renders the required data in the email table, no matter what i try it only shows the ppe sheet but if i remove the
    ppe line it errors, how/where do i add the coding so that it will go through every sheet and render the different data from each sheet into individual email tables.

    any help would be appreciated as this is now doing my head in

    Peter
    Attached Files Attached Files

  6. #6
    Senior Member alansidman's Avatar
    Join Date
    Apr 2012
    Posts
    125
    Rep Power
    13
    Try the attached. Untested as I don't use Outlook as email client.
    Attached Files Attached Files

  7. #7
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    11
    Hi Alan

    Thanks for looking

    comes up with a runtime error on start up....method rows of object global failed..
    with this row highlighted (Set rng = w.Range("F4:F50" & w.Range("F" & Rows.Count).End(xlUp).Row - 1)


    Cheers Peter

  8. #8
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    Tested Alan's code and made some minor changes.
    This does the trick for me.
    Try it out and feel free to ask if you have any further problems.
    Attached Files Attached Files

  9. #9
    Member
    Join Date
    May 2013
    Posts
    84
    Rep Power
    11
    Thanks Bakerman

    that works spot on, i would never have got there in a month of sundays

    thanks also alan for your assistance..

    Peter:-)

  10. #10

Similar Threads

  1. Replies: 0
    Last Post: 07-24-2013, 11:20 PM
  2. Replies: 1
    Last Post: 06-12-2013, 07:42 PM
  3. Detect Duplicates In Named Ranges With Cross Check
    By Yegarboy in forum Excel Help
    Replies: 3
    Last Post: 10-09-2012, 11:02 AM
  4. Setting up a check box
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 08-07-2012, 08:26 AM
  5. Loop and Check For Values In Entire Column in Excel
    By Jeff5019 in forum Excel Help
    Replies: 3
    Last Post: 05-01-2012, 10:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •