+ Reply to Thread
Results 1 to 7 of 7

if not wrksht is nothing VS if wrksht is nothing

  1. #1
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    180

    if not wrksht is nothing VS if wrksht is nothing

    I am mystified why people will check if a worksheet exists by using the negative:

    If NOT worksheet is nothing then
    exists
    else
    does not exist
    endif


    VERSUS



    if worksheet is nothing then
    does not exist
    else
    does exist
    endif


    the latter code seems significantly more clear to me. Any insights?

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: if not wrksht is nothing VS if wrksht is nothing

    Please Login or Register  to view this content.
    means If worksheet exists

    Edited:
    ...............Ignore................
    Did not read post correctly
    Last edited by Sintek; 05-29-2017 at 01:51 PM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    02-13-2016
    Location
    CT USA
    MS-Off Ver
    office 365 subscription
    Posts
    180

    Re: if not wrksht is nothing VS if wrksht is nothing

    Thank you, Sintek, I appreciated your taking your valuable time to respond.

    I guess I objected to the double negative to derive a meaning.

    I prefer the second version. Just wanted to make sure I was not getting into any trouble.

    bil

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: if not wrksht is nothing VS if wrksht is nothing

    Either or I guess:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I prefer the first as I would not use the code unless i want to do something with the worksheet and skip the Else part

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: if not wrksht is nothing VS if wrksht is nothing

    The above codes will error before reaching the "don't exists" branch.
    To take advantage of the On Error Resume Next, one could use this contraction.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: if not wrksht is nothing VS if wrksht is nothing


    Hi !

    Or instead just use ISREF worksheet function …

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: if not wrksht is nothing VS if wrksht is nothing

    @mikerickson
    The above codes will error before reaching the "don't exists" branch.
    Of course - Out of range...

+ 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. wiew get the end of the wrksht, how to fix wiev the top of the wrksht
    By sugee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-10-2013, 02:28 AM
  2. Transfer data from report wrksht to another work book log wrksht
    By RAMPFGroup in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-02-2012, 10:29 AM
  3. [SOLVED] Show hidden wrksht(s) by clicking a button on an always visible wrksht, in same wrkbk
    By jakeh2475 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2012, 01:35 AM
  4. pull comments on a wrksht and list as text in cells on another wrksht
    By ronocnikral in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-19-2009, 09:14 AM
  5. how do I get the cell to move to the right instead of the wrksht?
    By Stephen Matejov in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-30-2006, 11:25 AM
  6. [SOLVED] Shade a cell on one wrksht if another wrksht cell is occupied
    By Clark in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-22-2006, 01:36 PM
  7. Replies: 7
    Last Post: 01-24-2006, 03:30 PM
  8. work with 2 different wrksht on same screen
    By dharr0917 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-22-2005, 07:58 PM

Tags for this Thread

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