+ Reply to Thread
Results 1 to 26 of 26

Modify IF Formula

Hybrid View

  1. #1
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Modify IF Formula

    I have this formula in one of my sheets which is working ok but if the statement is False it adds up an empty row which I don’t like it

    =IF(LEFT(Entry!B15,3)="Design",Entry!B15,"")

    Is there anyway to modify this formula so when the "Entry" sheet doesn't contain "Design" the formula does nothing?

    Would it be better to use a Vlookup formula and if yes how is the syntax?

    I prefer not to use a Macro or VB code

  2. #2
    Valued Forum Contributor
    Join Date
    04-03-2012
    Location
    East Sussex, UK
    MS-Off Ver
    Excel 2003:2010
    Posts
    893

    Re: Modify IF Formula

    From what I can see, that formula will always fire as false. You're asking for the left three characters of cell B15 to = "Design". Design is 6 characters so that's never going to be true.

    Perhaps you need =IF(LEFT(Entry!B15,6)="Design",Entry!B15,"")
    If I've been of help, please hit the star

  3. #3
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    My fault, sorry, it is 6. I design a new workbook and working on several alternatives and guess I mixed up things

    In any case is it possible to have no action when the formula is False and avoid the empty row i get now

    Is VLOOKUP a better way?

  4. #4
    Valued Forum Contributor
    Join Date
    04-03-2012
    Location
    East Sussex, UK
    MS-Off Ver
    Excel 2003:2010
    Posts
    893

    Re: Modify IF Formula

    What do you want to be there instead of the empty cell?

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    doesn't matter what formula you use you are still going to end up with something in the cell the formula is in. what do you mean by "it adds up an empty row"?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    I have attached a sample file to indicate the empty rows I get

    I know it happens because on the "Entry" sheet I dont have "Design" entries but I wonder if there is a way to modify the formula to avoid having empty rows on the "Design" sheet.

    Also I thought if I would use VLOOKUP may be better?
    Attached Files Attached Files

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    i'd add a helper column on each of the 3 sheets then use index/match to get the values
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    Quote Originally Posted by martindwilson View Post
    i'd add a helper column on each of the 3 sheets then use index/match to get the values
    I print some instructions from the web on the new functions (Index, Count, Rows, Max, Match) and study them but they did not provide me with any more info regarding the new Index column C

    Looking at the Index columns, I notice that the numbers are in ascending order but the Design sheet has many more than the other sheets and why the space between these number?

    I would appreciate it if you can give me a little insight on the Index column C use

    Cheers

  9. #9
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    That’s pretty neat Martin, thanks so much

    It looks that is working really well and don’t mind the new index column.

    I will study the new formulas to see if I understand them just so I can educate myself

    Much appreciated

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    look at on the design sheet
    INDEX(Entry!$A:$B,MATCH(ROWS($A$1:$A1),$C:$C,0),1)
    then examine the
    MATCH(ROWS($A$1:$A1),$C:$C,0)
    when filled down it changes to
    =MATCH(ROWS($A$1:$A1),$C:$C,0) note ROWS($A$1:$A1) =1 ROWS($A$1:$A2) =2 and so ion
    =MATCH(ROWS($A$1:$A2),$C:$C,0)
    =MATCH(ROWS($A$1:$A3),$C:$C,0)
    =MATCH(ROWS($A$1:$A4),$C:$C,0)
    =MATCH(ROWS($A$1:$A5),$C:$C,0)
    ie
    =MATCH(1,$C:$C,0)
    =MATCH(2,$C:$C,0)
    =MATCH(3,$C:$C,0)
    =MATCH(4,$C:$C,0)
    =MATCH(5,$C:$C,0)
    now you can see it matches say the number in column c and returns the row
    =MATCH(1,$C:$C,0) =2
    =MATCH(2,$C:$C,0) =5
    =MATCH(3,$C:$C,0) =7
    =MATCH(4,$C:$C,0) =8
    used inside index gives
    INDEX(Entry!$A:$B,2,1)ie Entry!$A2
    INDEX(Entry!$A:$B,5,1) ie Entry!$A5
    INDEX(Entry!$A:$B,7,1)ie Entry!$A7
    INDEX(Entry!$A:$B,8,1)ie Entry!$A8

  11. #11
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    Thanks for your time Martin

    Sorry for my ignorance but have some difficulty right now understanding these functions.

    For example on the Design sheet, rows 3 & 4 there are 2 Design entries but there is no numbers in column C. Why?

    As I design my new workbook, I will add perhaps 10-15 more sheets (like parts, specifications, metallurgy, etc) and my main concern is how do I figure out what numbers I will write in column C?

    Perhaps I copy the formulas into my new sheets and it will work?

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    the numbers in col c are obtained by checking col b of entry sheet , they mark the rows that match
    if you put =IF(LEFT(Entry!B2,6)="design","yes","") you'd get yes in the row every time corredponding row on entry sheet starts with design
    but since i needed an unique number i used
    =IF(LEFT(Entry!B2,6)="design",MAX($C$1:C1)+1,"") so instead of "yes" every time the condition is true it adds 1 to the max of the previous cell
    s
    starting in c2 =MAX($C$1:C1)+1
    c1 is empty so MAX($C$1:C1) is 0 but LEFT(Entry!B2,6)="design" so add 1 so put 1 in c2
    so when filled down to c3 =MAX($C$1:C2)+1 but LEFT(Entry!B2,6)<>"design" so leave blank
    c4 =MAX($C$1:C3)+1 but LEFT(Entry!B2,6)<>"design" so leave blank again
    c5 =MAX($C$1:C4)+1 but LEFT(Entry!B2,6)="design" add 1 to max of MAX($C$1:C4) which becomes 2 ie the max of(1,blank,blank)+1

  13. #13
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    Thank you for your patience Martin

    I printed your last 2 emails and I now study them and think I'm getting there; I want to understand them so in the future if I have any problems I can fix them myself

    Cheers

  14. #14
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    I now understand what you say in your last 2 emails Martin but I observed the following which in my point of view are confusing:

    On the Entry form I noticed you have put some sequential numbers next to the text of each entry (Row 2 design you have 1, row 5 design you have 2, etc). I erased these numbers to see what affect they have and looks like that nothing changed. Do these numbers perform something?

    On your last email you said "the numbers in col c are obtained by checking col b of entry sheet, they mark the rows that mach". My observation does not agree with this statement but of course I may be wrong

    For example on the entry sheet the first four entries for design are in rows 2, 5, 7 & 8

    Now if I check column c on the design sheet I see these numbers

    column c value in row 2 = 1
    column c value in row 3 = nothing
    column c value in row 4 = nothing
    column c value in row 5 = 2

    Do I read something wrong?

  15. #15
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    read about index/match here
    http://www.contextures.com/xlFunctions03.html

  16. #16
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    For example on the entry sheet the first four entries for design are in rows 2, 5, 7 & 8
    so on design sheet you will see
    column c value in row 2 = 1
    column c value in row 3 = nothing
    column c value in row 4 = nothing
    column c value in row 5 = 2
    column c value in row 6 = nothing
    column c value in row 7 = 3
    column c value in row 8 = 4
    thats correct now match 1, in column c it will return 2 letting us know which row for use in the index of the columns on entry sheet
    match 2, in column c it will return 5
    match 3, in column c it will return 7
    match 4, in column c it will return 8

  17. #17
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    Thanks again so much Martin

    Cheers

  18. #18
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    here is an explanation all on one sheet to see if you can see it better
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    Great work Martin, took me some time to understand your nicely done file but now I can see how the formulas work together

    Many thanks again

    Cheers

  20. #20
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    Hi Martin

    Working on my file I discovered that if I press F2 to edit an entry on the "Design" sheet I only see the formula and not the entry. Is it easy to fix this problem?

    If not I will find another way to go about it because I really like what you did and works well

  21. #21
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    why f2? that displays the formula i'm not sure what you mean

  22. #22
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    Hello Martin

    Go to the file you posted on Post 7 and on the design sheet try to edit any entry. I do this by selecting the row I want to edit and pressing F2. What I get is the formula and I'm not able to edit the entry

  23. #23
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Modify IF Formula

    i don't understand what do you want to edit? you can edit the formula or edit the data on entry! sheet it wont work backwards

  24. #24
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    That's what I thought Martin and its ok

    However the idea of having the various sheets (Design, Purchasing, etc) was to have a separate record of each on different sheets. Now lets say 6 months later I may have 100 entries on the Design sheet and if I notice an error or I want to add something on this record I should be able to do it without trying to find the same record on the Entry sheet.

    Thanks again, your help has been more than excellent

  25. #25
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,825

    Re: Modify IF Formula

    Oskar

    I have been following this thread, which is related to your thread about calendars which I've already responded to - I hope Martin doesn't mind me butting in.

    Using Martin's file, suppose you want to amend the entry which is in row 23 of the Design sheet. Scroll down column C of that sheet until you find 23, and note the row that it appears on - that is the row in the Entry sheet where you will find the original entry which you now want to amend, so it is relatively easy to do the amendment on the Entry sheet, and of course it will automatically reflect back on the Design sheet (well, as long as you keep "Design" as the first word).

    Hope this helps.

    Pete

  26. #26
    Registered User
    Join Date
    09-26-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2002
    Posts
    63

    Re: Modify IF Formula

    That is an easy way of amending an entry, thanks for your time Pete

+ 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