+ Reply to Thread
Results 1 to 14 of 14

Delete cells based on value and update chart area

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Delete cells based on value and update chart area

    Hello, I have a list of data that I am making a graph with. However, some of the data contains a zero and I would like to remove these from the list. After removing all of the data with a zero entry, I would like to update the area on my graph. The data has item# starting in F2 then going down, and a quantity starting in G2 going down. I would like the script to go through the column and every time it finds a zero value in the G cell, it deletes that cell as well as the cell in column F right next to it. After deleting the cell it should shift the cells below it upwards.

    Also, after the useless data has been taken out, I would like to update my chart area. Currently I have a chart that is over 1000 values wide, yet only about 320 are needed. The data will expand with time and I'd like the chart area to update each time the list is sorted. Thank you very much.


    EDIT: I should probably also specify that I'm looking for just the cells in column G and F to be deleted when the value in G is zero, not the entire row.
    Last edited by sczerniak; 07-19-2013 at 03:09 PM. Reason: solved

  2. #2
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    try this
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    Please Login or Register  to view this content.
    here a better one that will delete the row which contain zero

  4. #4
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    is it working?

  5. #5
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Delete cells based on value and update chart area

    No, and it erased all of my data. Thankfully I had a backup saved and was able to recover it. Also, I'm not trying to delete the entire row only the values in G and F if G is zero. Here's an example:

    [COL F][COL G]
    Item1 5
    Item2 8
    Item3 0
    Item4 12
    Item5 3
    Item6 0
    Item7 0
    Item8 4

    In the example table above, I would want the code to recognize that column G has a zero value and then delete those two cells in G and F. Therefore, the resulting table would look like this:

    [COL F][COL G]
    Item1 5
    Item2 8
    Item4 12
    Item5 3
    Item8 4
    Last edited by sczerniak; 07-11-2013 at 03:57 PM.

  6. #6
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    sorry for that..he what you want!

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    sorry for that..he what you want!

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Delete cells based on value and update chart area

    Quote Originally Posted by extremis View Post

    Please Login or Register  to view this content.
    No. I don't want to delete the entire row.

    I got an idea from your macro and now I'm able to delete the ones that are zero. If anybody could help me with getting the chart area to be the cells that are left let me know. Thanks.

  9. #9
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    is it working?

    If it does..add to my reputation and make the post as solved

  10. #10
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Delete cells based on value and update chart area

    No need to be pushy, I would have given you the credit because you helped give me the idea for how to solve my problem. However, the entire post still isn't solved because there are two questions.

  11. #11
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    well..that would be another topic...!! as i said,

    add to my reputation and make the post as solved ..glad i helped!

  12. #12
    Forum Contributor
    Join Date
    04-26-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    167

    Re: Delete cells based on value and update chart area

    for the update..i would need to see your file so i could work on it !

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Delete cells based on value and update chart area

    Quote Originally Posted by extremis View Post
    well..that would be another topic...!! as i said,

    add to my reputation and make the post as solved ..glad i helped!
    Seems to me that the thread is NOT solved? The OP asked 2 questions, 1 linked to the other, and the 2nd part has not yet been touched?
    And to be quite honest, if it were me, you would not get any rep's from me after deleting all of my data.

    I have 2 suggestions for you -

    1. if there is a chance that your VBA will delete data - without the posibility of UNDO, warn the OP to save their data and to work on a back-up copy.
    2. dont be so pushy begging for rep points, they are given as a thank-you, they are not a right for responding to a thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  14. #14
    Registered User
    Join Date
    07-03-2013
    Location
    New England
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Delete cells based on value and update chart area

    Update: I solved the second question using a dynamic range.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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