+ Reply to Thread
Results 1 to 2 of 2

Delete Row when Cell Value = 0

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Question Delete Row when Cell Value = 0

    I am working with an excel spreadsheet to track all of our software, license keys, & where that software is currently installed. My workbook uses two sheets to do this, the first worksheet is named “Installed software” and the second one is called “Software”

    Software Sheet:
    I use this sheet to enter the software Name, Description, Version, Developer, Category, Date of Purchase, Supplier, Supplier Website, Price, License Type, Expiation /Renewal Date, Serial Number, & Quantity Purchased. I also have two fields that are calculation fields. These fields are Quantity Used & Quantity Remaining

    Installed Software Sheet:
    I use this sheet to enter the Name of User, a Description of Hardware, Asset Number, Date of Software Install, & Select Name of Software. Now this last field “Column G” I use a drop down field that looks at the “Software Sheet” that list all of software we have. Once I have chosen the software I am going to install from the list it changes the Calculation Field on the “Software Sheet”. i.e Quantity Used =1 & Quantity Remaining=0
    What I am trying to do is automatically hide that that row on the “Software Sheet” when Quantity Remaining=0 as well as automatically update the dropdown field in Column G on the “Installed Software” Sheet so that it won’t show that software as available for install. I have been attempting to approach it from the Installed Software Sheet to hide the row on the “Software’ sheet when I select the software from the drop down list in Column G but I have not been able to get this to work

    I have uploaded the sample worksheet
    Attached Files Attached Files

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Delete Row when Cell Value = 0

    Okay I think I've worked out a solution for you.

    Go ahead and see if the sheet at the bottom of this post works the way you want before installing it on any other sheet.

    What I've done is this. Like you wanted if a quantity remaining is 0 then the row gets hidden. If you remove one of your entries on the Installed Software sheet taking your quantity remaining from 0 back to a positive number the row will be visible again. The logical time to run the code was when the worksheet calculates so the code is in what's called the worksheet calculate event. Below is the code and if you need to install it in a different workbook you would need to right click on the tab for the sheet named Software and choose view code and paste the code into that sheet.

    It's important if the new workbook doesn't have a table with the exact same name as the sample sheet with the columns in the exact same place and named the same, then there will be issues we will have to work through.
    Please Login or Register  to view this content.
    The next thing is you wanted the software to disappear from the validation list if the row was hidden.
    I did this through code and with a named range. If you look under the named ranges you will see one named SoftwareValidationList.
    This refers to the software names listed on Sheet1 which I added. This sheet needs to stay. You can copy it to your actual sheet but you will have to recreate the named range. Just use the formula in the named range I created and you will be fine. You can also hide this sheet it doesn't need to be visible for the code to work. What happens is the code erases the entries on this sheet and refreshes them based on which rows are hidden and which are visible.
    If you look at the data validation for your drop down list on the Installed Software sheet you will see that I am listing that named range as the source for that list.

    The code for the updating of the Sheet1 list is below and is installed in what is called a standard module. After you put the code above in your actual sheet per the instructions I gave you, and while you are still in that same window, click on the insert menu and choose module. Copy and paste the code below into that screen. You will need to save your actual sheet as a .xlsm macro enabled worksheet for all of this to run.

    Make sure you test this on a copy of your sheet and let me know if you have any issues.

    Good Luck.

    Edit: I found a bug and it seemed to be caused by your Qty Used formula, the COUNTIF formula. I changed it using a Table reference.

    So the formula in O8 copied down is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by skywriter; 07-19-2015 at 01:28 AM.

+ 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. VBA code to delete the FILTERED range and moving the cell up (dont Delete entire row)
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2015, 07:48 AM
  2. [SOLVED] Delete cell only with certain critria. Don't want to delete entire row, the celsl only
    By RobertOHare in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2013, 04:18 AM
  3. Run Macro Automatically When delete row , changes cell,delete column
    By elevisse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2012, 07:42 AM
  4. Cell to Tab Macro Delete Tab when Cell Delete
    By Wskip49 in forum Excel General
    Replies: 4
    Last Post: 03-16-2011, 02:37 PM
  5. Delete Rows by Cell Value - Delete sheets w/out prompt
    By Jimmydageek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2010, 02:03 PM
  6. Delete entire row when cell says delete
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-27-2007, 11:46 AM
  7. Replies: 0
    Last Post: 05-24-2005, 05:42 AM

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