+ Reply to Thread
Results 1 to 11 of 11

Problem with isempty rule

  1. #1
    Registered User
    Join Date
    02-02-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    7

    Problem with isempty rule

    Hello, I have the following problem:

    I'm writting a macro that almost works. I only still have a problem with the following ruel:

    If IsEmpty(Sheets("Smeerlijst-Backlog").Cells(t, 3).Value) = False Then

    In the cell that i look if it is empty there stands a forumla that gives as result "X" or "" (blank).
    Now vba looks to the cell and always see the formula => is empty gives always "FALSE" as result !

    Now is my question: is there a way to say that vba don't looks at the formula but to the result of the formla?

    Thanks in advance

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Problem with isempty rule

    Hi, Frozenice,

    check the length of the cell:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    02-02-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Problem with isempty rule

    Mmm, it doesn't work. it now gives the following:

    Folt 13 during progress:

    types doesn't match

  4. #4
    Registered User
    Join Date
    02-02-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Problem with isempty rule

    Sub Smeerselectie()
    '
    ' Smeerselectie Macro
    ' Selecteren van smeerpunten uit planningsoverzicht
    '
    s = 5 ' startpunt
    e = 10 ' eindpunt
    t = 0 ' teller

    w = 16 ' weeknummer
    k = 2 + w ' kolomnummer

    For t = s To e

    If Len(Sheets("Planningsoverzicht").Cells(t, k).Value) = 1 Then

    Else
    Sheets("Planningsoverzicht").Activate
    Range(Cells(t, 1), Cells(t, 2)).Select
    Selection.Copy
    Sheets("Smeerlijst-Backlog").Select
    Cells(9, 1).Select
    Selection.Insert Shift:=xlDown
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End If

    Next

    End Sub

    This is the program.
    Sheets("Planningsoverzicht").Cells(t, k).Value, in this cel, on the worksheet "planningsoverzicht" there is standing an =if(..) function that gives as result on base of the logical test "" or X

    Grts Frozenice

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,835

    Re: Problem with isempty rule

    Now is my question: is there a way to say that vba don't looks at the formula but to the result of the formla?
    As you've discovered, a cell containing a formula is not empty. Are you consistent in using empty string as your placeholder? Does Sheets("Planningsoverzicht").Cells(t, k).Value="" return true?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Registered User
    Join Date
    02-02-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Problem with isempty rule

    Quote Originally Posted by MrShorty View Post
    As you've discovered, a cell containing a formula is not empty. Are you consistent in using empty string as your placeholder? Does Sheets("Planningsoverzicht").Cells(t, k).Value="" return true?
    I dont understand you question very well? Do you see some errors in my program?
    The programs works exept the "if" in the for loop

    grts

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Problem with isempty rule

    Hi, Frozenice,

    I ususally go with either what I suggested first (check the length of the cell)
    Please Login or Register  to view this content.
    which delivers 0 in the immediate window for
    Please Login or Register  to view this content.
    or compare the value of the cell to either "" or vbNullstring
    Please Login or Register  to view this content.
    which delivers True in my test workbook.

    Maybe you could attach a samll example of the worbook for testing if you canīt get it to work?

    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    02-02-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Problem with isempty rule

    Hello,

    In these reply i have added an example of my file.

    Can you let it work?

    Thanks in advance.

    Grts Mathias


    Smeerplan test.xlsx

  9. #9
    Registered User
    Join Date
    02-02-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Problem with isempty rule

    Hello,

    Do you find the problem in the program?

    Grts

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Problem with isempty rule

    Hi, Mathias,

    in the sample there werenīt only empty cells or "X" but errors which where caused by no values as starting dates in sheet Data. The codimng for empty strings or length will woprlk correcty if "" or "X" is in the cell but fail if an error is delivered. If you change the formulas accordingly you will get the code to work. Example for Range("R6") might look like
    Please Login or Register  to view this content.
    Ciao,
    Holger

  11. #11
    Registered User
    Join Date
    02-02-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Problem with isempty rule

    Hello,

    Thanks for the help. Now the program works :D

    Greetings Frozenice

+ 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