Solved

Filter for year and delete entire row

Posted on 2015-02-17
2
81 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

808 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