How to automatically delete rows in Excel 2007 based on cell value?
-
I'm looking to automatically delete rows in Excel 2007 based on whether or not there is a cell with a specific value in that row. I've Googled around, but I've only found old information on VBA scripts for previous versions of Excel and so far all of it is non-functional. I'm looking for a SuperUser quality explanation on how to do this.
-
Answer:
This macro will delete rows that contain cells with the "fri" value, and then shift the cells up. Just change "FRI" in the code to the value you'd like to search for. You could also modify it to prompt for a value or use the value from another cell as a criteria. Sub DeleteThis() For Each Rng In Selection.Rows If (Application.WorksheetFunction.CountIf(Rng, "fri") > 0) Then Rng.Delete Shift:=xlUp End If Next Rng End Sub To use: Select your data range, then run the macro. sample: before: after: Non-VBA: You can use Excel's Advanced Filters to select rows that meet certain criteria; although, it might require some sheet real estate and a few more steps.
hisnameisjimmy at Super User Visit the source
Related Q & A:
- How to add empty rows to the JQGrid?Best solution by Stack Overflow
- How I can display Rows into Columns?Best solution by Server Fault
- how to insert multiple rows from MySQL with checkbox?Best solution by Stack Overflow
- How to covert csv file to excel and back excel file to csv in python?Best solution by completecampaigns.com
- Does Facebook automatically delete friends?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.