+ Reply to Thread
Results 1 to 5 of 5

IF statement for all existing sheets in workbook

  1. #1
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Question IF statement for all existing sheets in workbook

    I am using the below working code to create sheets based on the values of a range of cells. If a worksheet with the same name already exists, then a new sheet is not created. When a worksheet gets created for the first time, I have the code looking for certain values on each sheet to see if they are "NONE" or 0. If those "NONE" or 0 values exist, then a range on the spreadsheet gets hidden. Here's where I need help: I want the same code that looks for the "NONE" and 0 values to do the same thing on the EXISTING sheets too (not just the newly created sheets). How should I modify my code below to have this evaluated for both new and existing sheets ?

    Please Login or Register  to view this content.
    Kind regards!

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: IF statement for all existing sheets in workbook

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Cheers!
    Deep Dave

  3. #3
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: IF statement for all existing sheets in workbook

    I have attached the workbook below for your reference:

    Example Workbook.xlsm

    It also would have been helpful if I put the corresponding function used in my prior code:

    Please Login or Register  to view this content.
    Kind regards!

  4. #4
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: IF statement for all existing sheets in workbook

    Well, I spent some time today and figured it out.. pretty easy fix, I just made the macro use the WorksheetExists function instead of focusing on the Worksheets that don't exist. The Sheets(MyCell.Value).Select runs through all the sheets that currently exist with names from MyRange of cells.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: IF statement for all existing sheets in workbook

    Hi,

    Good to hear you have your code working..

    I was on vacation hence could not reply..

    Cheers!

+ 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. [SOLVED] Merged mulitple sheets of existing workbook into one sheet
    By paradise2sr in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-01-2014, 04:04 AM
  2. Need help deleting sheets and moving existing sheets down in order
    By MAGICofSeth in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-27-2012, 06:13 PM
  3. Copying cells from existing sheets to new row of master sheet in one workbook
    By volcaremos in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-06-2012, 03:53 PM
  4. Create new sheets in existing workbook based on columns
    By NMullis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2012, 04:43 PM
  5. use existing creation date of workbook with newly created .saveas workbook
    By dwr0211 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-04-2011, 12:42 PM
  6. appending and IF statement to an existing IF statement
    By spence in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-28-2006, 07:10 PM
  7. [SOLVED] Copying existing sheets to another Workbook
    By Smonczka in forum Excel General
    Replies: 7
    Last Post: 06-15-2005, 09:05 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