?
Solved

EXCEL Macro to Delete Row

Posted on 2016-08-16
6
Medium Priority
?
77 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 32

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

801 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