Solved

EXCEL Macro to Delete Row

Posted on 2016-08-16
6
65 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 500 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 47

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 30

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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…

730 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