Solved

Filter for year and delete entire row

Posted on 2015-02-17
2
82 Views
Last Modified: 2015-02-17
Hi,

I need some VB code to filter for year "2015" in Column C and delete entire rows

Many thanks
Seamus
0
Comment
Question by:Seamus2626
[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
2 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 200 total points
ID: 40613788
Sub DeleteRows
   for introw = 99999 to 1 step -1
      if cells(introw,3)="2015" then
         rows(introw).delete
      end if
   next
End Sub
0
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 300 total points
ID: 40613789
HI,

pls try

    Range("C1").AutoFilter Field:=1, Criteria1:="2015"
    Range(Range("C2"), Range("C" & Cells.Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    ActiveSheet.Range("C1").AutoFilter

Open in new window

EDIT if you want to filter a date then use

    Range("C1").AutoFilter Field:=1, Criteria1:=">=" & CLng(DateValue("1.1.2015")), _
        Operator:=xlAnd, Criteria2:="<" & CLng(DateValue("1.1.2016"))
    Range(Range("C2"), Range("C" & Cells.Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    ActiveSheet.Range("C1").AutoFilter

Open in new window

Regards
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calculate number of months in Excel 13 26
Excel 2016 lost MRU list 8 66
why cannot i download this excel file? 7 27
Excel - Data Validation - Dynamic Weekday 11 22
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

740 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