+ Reply to Thread
Results 1 to 8 of 8

Specific sheet name macro help

  1. #1
    Forum Contributor
    Join Date
    08-08-2019
    Location
    CO
    MS-Off Ver
    Office 365
    Posts
    106

    Specific sheet name macro help

    Hey all,

    I am looking for help with a VBA code. I want to the script to run through the work book and only perform clearing out certain cells on specifically named sheets and to continue to execute the rest of the functions if that sheet doesn't exist. The problem I am running into is sometimes these reports do not have all the sheets (some are not needed). For example I have 6 sheets in a template that I need to account for (among many other sheets). So say I have sheets named PS1, PS2, PS3, PS4, PS5, and PS6. Most of the time these reports only contain PS1 and PS2, but I need it to check for all and not return an error if they do not exist. I will supply what I have so far. The problem lies inbetween ' Power Supply Clear and ' First Few Page Clear. All the rest works as intended. Thanks in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Specific sheet name macro help

    Just loop through the sheets, if it equals a specific sheet name then clear the cells.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-08-2019
    Location
    CO
    MS-Off Ver
    Office 365
    Posts
    106

    Re: Specific sheet name macro help

    Forgive my VBA ignorance, but am I to insert all of that code in between like so? I am including my entire macro as maybe this will shed some light. I receive a compile error expected end sub.

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Specific sheet name macro help

    Yes, you threw one sub inside another sub.

    I was just showing you how to loop through the sheets, if the sheet name = something then do something.

    Here is a more idealized example.

    Don't get caught up in the arrays and confusing stuff.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-08-2019
    Location
    CO
    MS-Off Ver
    Office 365
    Posts
    106

    Re: Specific sheet name macro help

    The Array portion is working perfectly in the top section. Its somewhat complicated what that code is doing. Is there just a way to execute what I am looking for with also keeping the top portion?

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,519

    Re: Specific sheet name macro help

    Maybe explain in a short but sweet manner what you want to accomplish. Be concise.
    All the "Selecting" in your code only slows down execution time and is not required.

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Specific sheet name macro help

    Sure,
    Add the additional code to your code and edit to suite your requirements.

  8. #8
    Forum Contributor
    Join Date
    08-08-2019
    Location
    CO
    MS-Off Ver
    Office 365
    Posts
    106

    Re: Specific sheet name macro help

    OK, I got all of it working now. Thanks guys for your help!

+ 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. Macro to filter specific range from specific sheet to another with unique values
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2018, 03:55 PM
  2. [SOLVED] Creating macro to populate specific cells from master sheet to work sheet
    By tatyanamarie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-01-2017, 03:19 AM
  3. [SOLVED] Macro to copy date to specific sheet based on data from another sheet.
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 08-09-2013, 11:28 AM
  4. Macro to prevent printing specific sheet based on cell value in another sheet
    By dbrady01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2013, 04:23 PM
  5. HELP! Macro to Copy specific cells from one sheet to another based on specific criteria
    By atriscritti in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-11-2012, 11:05 AM
  6. Macro to extract data from multiple workbooks, specific sheet, specific cells
    By crissandraauree in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 03:54 PM
  7. [SOLVED] How to get (range)macro to always run code on a specific sheet regardless of active sheet?
    By JTwrk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2012, 04:33 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