Solved

Filter for year and delete entire row

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

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

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

623 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