Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Filter for year and delete entire row

Posted on 2015-02-17
2
Medium Priority
?
88 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 800 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 53

Accepted Solution

by:
Rgonzo1971 earned 1200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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 article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

670 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