delete row if values <> on list
I've been using this for years however, i need to upgrade because of changing criteria.
Instead of this line in the code below:
If .Value <> "apples" And .Value <> "oranges" And .Value <> "peaches" And .Value <> "grapes" And .Value <> "cherries" And .Value <> "pecans" And .Value <> "cashews" And .Value <> "brazil" And .Value <> "oats" Then .EntireRow.Delete
I need to point to a list on the CONTROL SHEET starting at K16 to the last value in K.
Sub Delete_ROUTES_ColE()
Application.ScreenUpdating = False
Dim Firstrow As Long
Dim LastRow As Long
Dim Lrow As Long
With ActiveSheet
'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(2, 1).Row 'The 1 represents the RowIndex
LastRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
'Loop from Lastrow to Firstrow (bottom to top)
For Lrow = LastRow To Firstrow Step -1
'Check the values in the D column
With .Cells(Lrow, "E")
'This will delete each row that does NOT contain the
'multiple values "CITY TOTAL:" & "SINGLE 01" in Column D, case sensitive.
If .Value <> "apples" And .Value <> "oranges" And .Value <> "peaches" And .Value <> "grapes" And .Value <> "cherries" And .Value <> "pecans" And .Value <> "cashews" And .Value <> "brazil" And .Value <> "oats" Then .EntireRow.Delete
End With
Next Lrow
End With
Application.ScreenUpdating = True
End Sub
Anwsers to the Problem delete row if values <> on list
Download SmartPCFixer to Fix It (Free)
Hi,
Try this but a couple of things:-
1.
I'm not entirely sure what the Control sheet names is.
I called it 'Control' but is it called Control Sheet.
You may have to change it in the code.
2.
This deletes the rows if they don't appear in the list K6:Kn.
If it's the other way around and you want to keep things in the list change this line
If IsError(Application.Match(.Value, CtrlRng, 0)) Then
to this
If Not IsError(Application.Match(.Value, CtrlRng, 0)) Then
Sub Delete_ROUTES_ColE()
Application.ScreenUpdating = False
Dim Firstrow As Long
Dim LastRow As Long
Dim Lrow As Long
Dim CtrlRng As Range
LastRow = Sheets("Control").Cells(Cells.Rows.Count, "K").End(xlUp).Row
Set CtrlRng = Sheets("Control").Range("K6:K" & LastRow)
With ActiveSheet
'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(2, 1).Row 'The 1 represents the RowIndex
LastRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
'Loop from Lastrow to Firstrow (bottom to top)
For Lrow = LastRow To Firstrow Step -1
'Check the values in the D column
With .Cells(Lrow, "E")
If IsError(Application.Match(.Value, CtrlRng, 0)) Then
'This will delete each row that does NOT contain the
'multiple values "CITY TOTAL:" & "SINGLE 01" in Column D, case sensitive.
.EntireRow.Delete
End If
End With
Next Lrow
End With
Application.ScreenUpdating = True
End Sub
How to Avoid Downloading Malware
Where are you getting the download?
There are malicious people who download valid copies of a popular download, modify the file with malicious software, and then upload the file with the same name. Make sure you are downloading from the developer's web page or a reputable company.
Don't install download manager
Many sites suggest or require you to install an installer or a download manager before allowing you to download a program you may be interested in downloading. These tools almost always cause your computer more problems and may even have malware or other spyware. Avoid any site claiming anything must be installed first before you can continue with your download.
Avoid advertisements on download pages
To help make money and pay for the bandwidth costs of supplying free the software, the final download page may have ads. Watch out for anything that looks like advertisements on the download page. Many advertisers try to trick viewers into clicking an ad with phrases like "Download Now", "Start Download", or "Continue" and that ad may open a separate download.
Cancel or deny any automatic download
Some sites may automatically try start a download or give the appearance that something needs to be installed or updated before the site or video can be seen. Never accept or install anything from any site unless you know what is downloading.
Recommended Method to Fix the Problem: delete row if values <> on list:
How to Fix delete row if values <> on list with SmartPCFixer?
1. Click the button to download Error Fixer . Install it on your system. Open it, and it will scan your system. The errors will be shown in the scan result.
2. After the scan is done, you can see the errors and problems need to be fixed. Click Fix All.
3. When the Fixing part is done, your computer has been speeded up and the errors have been removed
Related: How to Update & Download NVidia GeForce 6100/nForce 420 WHQL Certified driver v.178.13,How to Update & Download NVidia GeForce 7600 GS Video Driver v.295.75 Certified,How Can I Update & Download NVidia GeForce 820M Driver v.344.48 WHQL,[Solved] Download NVidia GeForce GTX 560M VGA Driver v.296.17 Certified,Way to Update & Herunterladen NVidia GeForce GT 130M Video Treiber v.295.75 Certified,How to Update & Download SONY SVE14A1X1RH Realtek Ethernet Driver,Where to Download SONY SVS13A2W9ES Bluetooth Driver (Intel) v.2.6 - 2.6.23.40059,Best Way to Update & Download SONY VGN-CR203E Conexant HDAUDIO SoftV92 Data Fax Modem with SmartCP Setup Program v.7.62.0.50 driver,Best Way to Download SONY VGN-FE790G/N Wireless LAN Driver v.10.6.0.29,Method to Update & Download SONY VGN-NR31Z/S Firmware Extension Parser Device v.8.0.2.3,How to Fix Error 0x0000c1f5 SoluciĆ³n?,Error 0x80071a91 Win7 Fix Patch,Error 0x800ccc60 Windows Live Mail [Solved],Error Message 0x800ccc79 Outlook 2000 Fix,What is Error 0xc1ab0001?,[Answered] x64 saplugin dll,How to Fix Problem - Kb943729 Download?,Troubleshooting: Bccode D1 Error,Java Runtime Tech Support,Troubleshooting: ERROR NO SUCH GROUP Error
Read More: Delete Unique Records using a Macro,Tech Support: Decrease MailMerge Date Field,Troubleshoot:Deleting rows based on cell value using Autofilter Error,Tech Support: Deleting hotmail contacts - why does drop-down box still appear when I start typing in an address?,Tech Support: Cut and paste (sporadically and randomly) not working in Windows 7
No comments:
Post a Comment