Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 22

Thread: Expanding IF formula

  1. #1

    Expanding IF formula

    I am using this formula to get data from the sheet 'Uge1', but only if no one of the cells 'Uge1!D4' and 'Uge1!E4' are empty.

    =HVIS(ELLER(ER.TOM(Uge1!D4);(ER.TOM(Uge1!E4)));"";HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4))&" "&Uge1!F4)
    And here it is translated with my best school- english:

    =IF(OR(IS.EMPTY(Uge1!D4);(IS.EMPTY(Uge1!E4)));"";IF(MINUTE(Uge1!D4)>0;HOUR(Uge1!D4)&"."&MINUTE(Uge1!D4);HOUR(Uge1!D4))&"-"&IF(MINUTE(Uge1!E4)>0;HOUR(Uge1!E4)&"."&MINUTE(Uge1!E4);HOUR(Uge1!E4))&" "&Uge1!F4)
    Is it possible to expand the conditions so that if the cell 'Uge1!F4' is different from 'Rulleplan!D4', then target cell is not left empty (the part og formula after ;""; is getting the data)?

    I have been trying this:

    =IF(OR(IS.EMPTY(Uge1!D4);(IS.EMPTY(Uge1!E4)));Uge1!F4=Rulleplan!D4;"";IF(MIN ....
    but get error.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is this what you mean?

    =HVIS(OG(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4)),Uge1!F4=Rulleplan!D4);"";
    HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4))&" "&Uge1!F4)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    I've got an error using it.

    AND(Logic1;[Logic2];...)

    And part of the formula ",Uge1" was highlighted

  4. #4
    Changed comma to semicolon, and it works.
    Only now i get "0-0 700" (the "700" is what i want).
    It seems that when Uge1!D4 and Uge1!E4 is empty, it results in zeroes.
    I would like, when Uge1!D4 and Uge1!E4 is empty, but Uge1!F4 is different from Rulleplan!D4, only the content of Uge1!F4 is entered in the targetcell.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sorry about the comma.

    This assumes that you want the not equal test to take precedence

    =HVIS(OG(Uge1!F4<>Rulleplan!D4,Uge1F4;OG(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4)));"";
    HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4))&" "&Uge1!F4))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Got some errors trying to use your formula. Tryed to change it like this:
    =HVIS(OG(Uge1!F4<>Rulleplan!D4;OG(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4))));"";HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4))&" "&Uge1!F4)
    Worked just like before, except directly opposite (i got "0-0 700" when Uge1!F4 was equal to Rulleplan!D4) , so i chanced it to:
    [VCode]=HVIS(OG(Uge1!F4=Rulleplan!D4;OG(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4))));" ";HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4)) &"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4)) &" "&Uge1!F4)[/Code]
    and it worked just like your previos formula

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If F4 <> Rulleplan!D4 AND neither D4 nor E4 is blank, should it show F4 or the concatenated D4/E4 result?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Maybe i can explain what i want another way.
    This is the original formula:
    =HVIS(ELLER(ER.TOM(Uge1!D4);(ER.TOM(Uge1!E4)));"";HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4))&" "&Uge1!F4)
    This part:
    HVIS(ELLER(ER.TOM(Uge1!D4);(ER.TOM(Uge1!E4)));"";
    determine that if Uge1!D4 or Uge1E4 is empty, the target cells should be empty too.

    This part:
    HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4))&" "&Uge1!F4)
    put data in target cell different ways depending on minutes is zeroes or not and then add the content of Uge1!F4.

    What i want is, when Uge1!F4 is different from Rulleplan!D4 but Uge1!D4 or Uge1E4 is empty to put only the content of Uge1!F4 in the target cell.

  9. #9
    Sorry for the look of my reply, tryed to make it look like this
    Formula:
    =HVIS ....

  10. #10
    How do you do that
    Code:
    =HVIS .....


    Nihil sim

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Yes, we know that, but that condition could be met when D4 and E4 are also not blank, so which takes precedence?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  12. #12
    If Uge1!F4 = Rulleplan!D4 AND either Uge1!D4 or Uge1!E4 is blank, it should show blank
    If Uge1!F4 = Rulleplan!D4 AND either Uge1!D4 or Uge1!E4 is blank, it should show only the content of Uge1!F4.
    If both Uge1!D4 and Uge1!E4 is filled the rest of the code show the content of Uge1!D4 and Uge1!E4 and Uge1!F4

  13. #13
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =HVIS(Uge1!F4<>Rulleplan!D4;Uge1!F4;HVIS(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4));"";
    HVIS(MINUTE(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUTE(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUTE(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUTE(Uge1!E4);TIME(Uge1!E4))&" "&Uge1!F4))
    or, in English

    =IF(Uge1!F4<>Rulleplan!D4,Uge1!F4,IF(OR(ISBLANK(Uge1!D4),ISBLANK(Uge1!E4)),"",
    IF(MINUTE(Uge1!D4)>0,HOUR(Uge1!D4)&"."&MINUTE(Uge1!D4),HOUR(Uge1!D4))&"-"&IF(MINUTE(Uge1!E4)>0,HOUR(Uge1!E4)&"."&MINUTE(Uge1!E4),HOUR(Uge1!E4))&" "&Uge1!F4))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  14. #14
    If "Uge1!F4<>Rulleplan!D4" is true the formula now shows only Uge1!F4 even if data is entered in both Uge1!D4 and Uge1!E4.

    If i use:
    =HVIS(OG(Uge1!F4=Rulleplan!D4;OG(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4))));"";
    HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);
    TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);
    TIME(Uge1!E4))&" "&Uge1!F4)
    and both Uge1!D4 and Uge1!E4 is blank the formula shows "0-0 700", where the zeroes an the - comes from Uge1!D4 and Uge1!E4.

    Maybe the rest of the formula should be changed. The first part seemes to do what it is supposed to do.

    HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);
    TIME(Uge1!E4))&" "&Uge1!F4)

  15. #15
    I have been fiddling with the formula, this is what i have until now:

    =HVIS(OG(Uge1!F4=Rulleplan!D4;OG(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4))));"";
    HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);HVIS(TIME(Uge1!D4)>0;(TIME(Uge1!D4))&"-")
    &HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);HVIS(TIME(Uge1!E4)>0;(TIME(Uge1!E4))
    &HVIS(ER.TOM(Uge1!F4);"";HVIS(ELLER(ER.TOM(Uge1!D4);(ER.TOM(Uge1!E4)));Uge1!F4;" /"&Uge1!F4))))))
    If i enter data in Uge1!D4 AND Uge1!E4 the result is precisely what i want, whether i change Uge1!F4 or not.

    If i do not enter data in Uge1!D4 AND Uge1!E4 and change Uge1!F4 i get FALSEFALSE in the targetcell.

    If i do not enter data in Uge1!D4 AND Uge1!E4 and do not change Uge1!F4 i get blank in the targetcell (of course).

    Hope it helps, it did not help me.

  16. #16
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You've made a right mess of that haven't you?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  17. #17
    Yes, i think so.

  18. #18
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Compile a list of all possible variations of Uge1!D4 Blank/Not Blank, Uge1!F4 Blank/Not Blank, and Uge1!F4=/<>Rulleplan!D4 (I make that 8 variations), and then say what the result should be. I'll take a look tomorrow then.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  19. #19

    Post

    I will try.

    The workbook is calculating workinghoures for the employees and give a visible look at the covering of needed employees.
    The cells we are working on here is for 1 employee (me).
    U1!D4 and U1!E4 is in the format [t]:mm
    U1!F4 is standardformat
    Target cell is standardformat

    I have made a little change (non destructive ) in the formula so it looks like this:
     =HVIS(ELLER(ER.TOM(Uge1!D4);(ER.TOM(Uge1!E4)));"";_
    HVIS(MINUT(Uge1!D4)>0;TIME(Uge1!D4)&"."&MINUT(Uge1!D4);TIME(Uge1!D4))&"-"&HVIS(MINUT(Uge1!E4)>0;TIME(Uge1!E4)&"."&MINUT(Uge1!E4);TIME(Uge1!E4))_
    &HVIS(ER.TOM(Uge1!F4);"";HVIS(ELLER(ER.TOM(Uge1!D4);(ER.TOM(Uge1!E4)));Uge1!F4;" /"&Uge1!F4)))
    Here is the list (RP! = Rulleplan!:

    Uge1!D4=Empty | Uge1!E4=Empty | Uge1!F4=RP!D4 | Target cell = Empty
    Uge1!D4=Empty | Uge1!E4=Empty | Uge1!F4<>RP!D4 | Target cell = Uge1!F4
    Uge1!D4=Filled | Uge1!E4=Empty | Uge1!F4=RP!D4 | Target cell = Empty
    Uge1!D4=Filled | Uge1!E4=Empty | Uge1!F4<>RP!D4 | Target cell = Uge1!F4
    Uge1!D4=Empty | Uge1!E4=Filled | Uge1!F4=RP!D4 | Target cell = Empty
    Uge1!D4=Empty | Uge1!E4=Filled | Uge1!F4<>RP!D4 | Target cell = Uge1!F4
    Uge1!D4=Filled | Uge1!E4=Filled | Uge1!F4=RP!D4 | Target cell = Uge1!D4&-&Uge1!E4
    Uge1!D4=Filled | Uge1!E4=Filled | Uge1!F4<>RP!D4 | Target cell = Uge1!D4&-&Uge1!E4& /&Uge1!F4

    Example:

    Rulleplan!D4=700

    Uge1!D4 [Empty] | Uge1!E4 [Empty] | Uge1!F4 [700] | Target Cell [Empty]
    Uge1!D4 [Empty] | Uge1!E4 [Empty] | Uge1!F4 [900] | Target Cell [900]
    Uge1!D4 [7:00] | Uge1!E4 [Empty] | Uge1!F4 [700] | Target Cell [Empty]
    Uge1!D4 [7:00] | Uge1!E4 [Empty] | Uge1!F4 [900] | Target Cell [900]
    Uge1!D4 [Empty] | Uge1!E4 [15:00] | Uge1!F4 [700] | Target Cell [Empty]
    Uge1!D4 [Empty] | Uge1!E4 [15:00] | Uge1!F4 [900] | Target Cell [900]
    Uge1!D4 [7:00] | Uge1!E4 [15:00] | Uge1!F4 [Empty] | Target Cell [7-15]
    Uge1!D4 [7:00] | Uge1!E4 [14:30] | Uge1!F4 [Empty] | Target Cell [7-14.30]
    Uge1!D4 [7:00] | Uge1!E4 [15:00] | Uge1!F4 [700] | Target Cell [7-15 /700]
    Uge1!D4 [7:00] | Uge1!E4 [14:30] | Uge1!F4 [900] | Target Cell [7-14.30 /900]


    The part of the formula that makes the U1!F4-part of the targetcell look different
    ("900" or "7-14.30" or "7-14.30 /900") is this:
    &HVIS(ER.TOM(Uge1!F4);"";HVIS(ELLER(ER.TOM(Uge1!D4);(ER.TOM(Uge1!E4)));Uge1 !F4;" /"&Uge1!F4)))

    Tried to make the listings look like tables. Not easy in here

  20. #20
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Here we go then my friend

    =HVIS(ELLER(ER.TOM(Uge1!D4);ER.TOM(Uge1!E4));HVIS(Uge1!F4=Rulleplan!D4;"";Uge1!F4);
    TEKST(Uge1!D4;HVIS(MINUT(Uge1!D14)=0;"h";"h:mm"))&"-"&
    TEKST(Uge1!E4;HVIS(MINUT(Uge1!E4)=0;"h";"h:mm"))&
    HVIS(ER.TOM(Uge1!F4);"";" /"&Uge1!F4))
    In English

    =IF(OR(ISBLANK(Uge1!D4),ISBLANK(Uge1!E4)),IF(Uge1!F4=Rulleplan!D4,"",Uge1!F4),
    TEXT(Uge1!D4,IF(MINUTE(Uge1!D14)=0,"h","h:mm"))&"-"&
    TEXT(Uge1!E4,IF(MINUTE(Uge1!E4)=0,"h","h:mm"))&
    IF(ISBLANK(Uge1!F4),""," /"&Uge1!F4))
    You might need to change the Text formats, I use h and H:mm for hours and hours and minutes. Danish might be other letters.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •