Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

EXCEL Macro to Delete Row

Posted on 2016-08-16
6
Medium Priority
?
80 Views
Last Modified: 2016-08-16
Hello,
can you please help with a macro,
Delete Rows,
if Column "D" duplicates, and if Column "K" value is 0$ and there is another value in column 'K"
then Delete Row with 0$.

if Column "D" duplicates , and the value in Column "K" IS 0$ and there is NO another value in column 'K", then , do not delete row.

if no duplicates in Column "D", then do nothing.

Attached is ample, before, after

I have about 4000- 5000 in each column
Your help is appreciated,
Sample.xlsx
0
Comment
Question by:W.E.B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Accepted Solution

by:
Martin Andrews earned 2000 total points
ID: 41758342
Here you go.  It removes the duplicate zero entries that you had in your desired output, though, which I think is what you actually want.
Sample2.xlsm
0
 
LVL 2

Expert Comment

by:Martin Andrews
ID: 41758350
You just need to click on the Macros button in the Developer tab and run the cleanup script
0
 
LVL 2

Expert Comment

by:Martin Andrews
ID: 41758355
If you can't see the Developer tab, click on the File menu and then select Options from the drop down menu. When the Excel Options window appears, click on the Customize Ribbon option on the left. Click on the Developer checkbox under the list of Main Tabs on the right. Then click on the OK button
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 49

Expert Comment

by:Martin Liss
ID: 41758360
In case you need them, here are instructions on how to install and use a macro.

In Excel, Press Alt+F11 to open the Visual Basic Editor (VBE)

Right-click on your workbook name in the "Project-VBAProject" pane (at the top left corner of the editor window). If you don’t see an existing module then select Insert -> Module from the context menu. Otherwise just select the module.

Copy the macro (you can use the ‘Select All’ button if you like) and paste it into the right-hand pane of the VBA editor ("Module1" window)

Press Alt+F11 again to go back to Excel

Optionally, press Alt+F8 to open the "Macro" dialog window. Select the macro, click ‘Options…’,  hold down the Shift key and type the letter A (or any other letter) and click ‘OK’. Then anytime you want to run the macro press Ctrl+Shift+A.

When you close the workbook you will need to save it as an xlsm or xls file if it’s not already one of those.
0
 
LVL 33

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41758370
Please try this.....

Sub DeleteRows()
Dim lr As Long
Application.ScreenUpdating = False
lr = Cells(Rows.Count, 4).End(xlUp).Row
Columns(12).Insert
Range("L2:L" & lr).Formula = "=IF(AND(COUNTIF($D$2:$D$" & lr & ",D2)>1,SUMIF($D$2:$D$" & lr & ",D2,$K$2:$K$" & lr & ")>0,K2=0),1,"""")"
On Error Resume Next
Range("L2:L" & lr).SpecialCells(xlCellTypeFormulas, 1).EntireRow.Delete
Columns(12).Delete
Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Closing Comment

by:W.E.B
ID: 41758378
Super,
Merci, Thank you.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question