+ Reply to Thread
Results 1 to 8 of 8

An 'IF NOT ISEMPTY' syntax query

  1. #1
    Registered User
    Join Date
    04-09-2006
    Location
    London
    Posts
    70

    An 'IF NOT ISEMPTY' syntax query

    Hi,

    I wrote a macro as practice and in that macro I used the 'UsedRange' to identify the columns and rows being used up by data.

    then I used the following syntax to identify any empty columns in between so they can be ignore by the code and the code can move on to the next column.

    Please Login or Register  to view this content.
    What the above code is meant to do is ignore the column no. 'iCol' if its empty. However VBA does not like it and while it doesnt give me any sort of error, it does not bypass the empty column either. What am I doing wrong here?

    Also, even though I have read a bit on Integer and Double (& singles), I still am not comfortable with the differences. TO my mind, there would be hardly any use for doubles to be specifed as data type, can anyone shed some light please.

    Cheers,
    I LOVE THIS PLACE!!!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: An 'IF NOT ISEMPTY' syntax query

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: An 'IF NOT ISEMPTY' syntax query

    I usually go with something along the lines of
    if cells(x, y) <> "" then

    or

    if cells(x, y) <> vbNullString then

    And your question is a good one regarding doubles, singles, integers, etc. I think what it ultimately comes down to is efficiency. The more simple you can keep a program, the faster it will run. This doesn't seem like a problem on a small scale, but if you're dealing with a massive amount of calculations, you'll want to declare everything in the simplest fashion possible to speed up your code.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  4. #4
    Registered User
    Join Date
    04-09-2006
    Location
    London
    Posts
    70

    Re: An 'IF NOT ISEMPTY' syntax query

    Quote Originally Posted by shg View Post
    Please Login or Register  to view this content.
    Shg, thankyou again for the help. Out of curiosity what is wrong with my code and should it not work?

    Cheers again

  5. #5
    Registered User
    Join Date
    04-09-2006
    Location
    London
    Posts
    70

    Re: An 'IF NOT ISEMPTY' syntax query

    Quote Originally Posted by mewingkitty View Post
    I usually go with something along the lines of
    if cells(x, y) <> "" then

    or

    if cells(x, y) <> vbNullString then

    And your question is a good one regarding doubles, singles, integers, etc. I think what it ultimately comes down to is efficiency. The more simple you can keep a program, the faster it will run. This doesn't seem like a problem on a small scale, but if you're dealing with a massive amount of calculations, you'll want to declare everything in the simplest fashion possible to speed up your code.
    Cheers Mewingkitty for the info. So atleast for the time being, I can just ignore all the other numbers and just keep my focus on the integers for defining numbers

    All the best,

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: An 'IF NOT ISEMPTY' syntax query

    Hello Kayote,

    If row 1 is header row, here is another method you can use...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: An 'IF NOT ISEMPTY' syntax query

    From Help:
    IsEmpty(expression)

    The required expression argument is a Variant containing a numeric or string expression. However, because IsEmpty is used to determine if individual variables are initialized, the expression argument is most often a single variable name.

    Remarks

    IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty; otherwise, it returns False. False is always returned if expression contains more than one variable. IsEmpty only returns meaningful information for variants.
    What you're testing with IsEmpty(someRange.Value) is the variant that the Value property returns. If there is more than one cell in the range (e.g., your code and Leith's suggestion), it will always return False.

  8. #8
    Registered User
    Join Date
    04-09-2006
    Location
    London
    Posts
    70

    Re: An 'IF NOT ISEMPTY' syntax query

    Leith Ross and Shg, thankyou ever so much for the help.

    Regards,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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