+ Reply to Thread
Results 1 to 15 of 15

If statement, then sum, replace and delete.

  1. #1
    Registered User
    Join Date
    10-11-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2002
    Posts
    71

    If statement, then sum, replace and delete.

    Hi there.. I am having some trouble with an if statement that it is way to complicated for me..

    I will link the xls file so that you can try it out, but i'll explain carefully here!
    (xls file attached at the end)

    What I want for each cell in H.
    Please Login or Register  to view this content.
    So for example H6 will first be noticed by if, then I want it to sum I5 and I6 as "NewNominal" and sum J5 and J6 as "NewMarketValue"
    then replace I5 with "NewNominal" and J5 with "NewMarketValue". Then Delete the row pending(Row6), then move to the next "Pending:" Value!

    Anyone that can kick meo ff or maybe complete a code for it?

    Regards, C

    XLS FILE ATTATCHED: Copy of PoolAccountPending.xls

  2. #2
    Forum Contributor
    Join Date
    03-21-2013
    Location
    Corvallis, OR
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: If statement, then sum, replace and delete.

    Try this:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If statement, then sum, replace and delete.

    Another one.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-11-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2002
    Posts
    71

    Re: If statement, then sum, replace and delete.

    Worked perfect, thank you!

    Do you know if it's possible to add a row counter instead of using "m"?

  5. #5
    Forum Contributor
    Join Date
    03-21-2013
    Location
    Corvallis, OR
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: If statement, then sum, replace and delete.

    christopherL, AB33's code will work also, unless you intend on having more data below your 2000 rows that you wanted to ignore. It will work better (no change in code needed) if you ever have more than 2000 rows of applicable data though.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If statement, then sum, replace and delete.

    Do you know if it's possible to add a row counter instead of using "m"?

    Yes, you can as it is a number. My counter is "I"

  7. #7
    Registered User
    Join Date
    10-11-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2002
    Posts
    71

    Re: If statement, then sum, replace and delete.

    Hey mate, I used yours to, and it worked really smooth for me. Thank you
    I just noticed a second thing I wanted to adjust.. After this if statement is complete, I want to delete the rows with a nominal or market value = 0.

    Do I add this in the if statement I have now, or a completely new with?
    If you cba you can write it or else I will give it my best

    Regards

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If statement, then sum, replace and delete.

    Bmxfreedom,
    It does not matter if the number of rows are 10, or 1m since the condition of testing each row is "Pending".
    It is also efficient to use the last non empty row, instead of a fixed row. If the last row in column H is 10, the code has still need to loop 2000 times.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: If statement, then sum, replace and delete.

    Here is another solution:

    Please Login or Register  to view this content.
    Last edited by alansidman; 11-07-2013 at 11:47 AM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  10. #10
    Forum Contributor
    Join Date
    03-21-2013
    Location
    Corvallis, OR
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: If statement, then sum, replace and delete.

    AB33's code should do what I think you mean by row counter.

  11. #11
    Registered User
    Join Date
    10-11-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2002
    Posts
    71

    Re: If statement, then sum, replace and delete.

    Thanks all of you, I have never experienced such great hospitality and quick response before! I am astonished, thanks all of you

  12. #12
    Forum Contributor
    Join Date
    03-21-2013
    Location
    Corvallis, OR
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: If statement, then sum, replace and delete.

    Quote Originally Posted by AB33 View Post
    Bmxfreedom,
    It does not matter if the number of rows are 10, or 1m since the condition of testing each row is "Pending".
    It is also efficient to use the last non empty row, instead of a fixed row. If the last row in column H is 10, the code has still need to loop 2000 times.
    Thanks for the extra clarification. I understand this, I just didn't know christopherL's reason for the 5 to 2000 setup. In many of my own cases, I have data in a set of rows that need something like this done, then more data below that need to be ignored. Now that I really think about it though, deleting the pending rows would indicate that isn't the case, unless christopherL meant to just have their contents cleared instead of the entire row deleted.

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If statement, then sum, replace and delete.

    Try the attached.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If statement, then sum, replace and delete.

    Another one.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    10-11-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2002
    Posts
    71

    Re: If statement, then sum, replace and delete.

    Perfect, thank you mate!

+ 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. Replace & Delete
    By manicman in forum Excel General
    Replies: 0
    Last Post: 03-17-2011, 12:49 PM
  2. Replace 0s with blanks - IF statement
    By thomas.szwed in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-12-2007, 11:59 AM
  3. Can I create an If Statement that will replace text
    By kalikw in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-29-2006, 09:40 PM
  4. Replies: 1
    Last Post: 03-08-2006, 06:10 AM
  5. How do I use an if statement with Find and Replace
    By Gerald in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-03-2005, 06:05 PM

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