+ Reply to Thread
Results 1 to 6 of 6

Autofiltering then adding a value to filtered rows

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    Charlotte, NC
    MS-Off Ver
    2010
    Posts
    4

    Autofiltering then adding a value to filtered rows

    Hello,

    I am able to autofilter a sheet to show only rows with a date in Column U but no "x" in Column BC. Now I want to be able to put an "x" in BC in only the filtered rows. The purpose is if someone enters a date in Column U, the macro will show only those rows minus the rows that have already had an "x" added to BC.

    For the most part I've gotten this to work using but it will also put an "x" in Column BC, row 3001 on down.

    How can I get it to stop at the last row?


    Thanks!

    Cells.AutoFilter Field:=21, Criteria1:="<>"
    Cells.AutoFilter Field:=55, Criteria1:="="

    Columns(55).SpecialCells(xlCellTypeVisible).Value = "X"

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Autofiltering then adding a value to filtered rows

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    Charlotte, NC
    MS-Off Ver
    2010
    Posts
    4

    Re: Autofiltering then adding a value to filtered rows

    Sorry but I am completely new to this. How do I integrate it with what I have? It's not placing any x's in the cells.

    Here is my macro with yours appended and hide columns added in.

    Sub Template_NEW()

    Cells.AutoFilter Field:=21, Criteria1:="<>"

    Cells.AutoFilter Field:=55, Criteria1:="="

    Columns("B:D").EntireColumn.Hidden = True

    Columns("G:T").EntireColumn.Hidden = True

    Columns("W:W").EntireColumn.Hidden = True

    Columns("Y:Y").EntireColumn.Hidden = True

    Columns("AA:AZ").EntireColumn.Hidden = True

    Dim y As Long
    y = Range("BC" & Rows.Count).End(3).Row
    Range(Cells(2, "BC"), Cells(y, "BC")).SpecialCells(xlCellTypeVisible).Value = "X"

    End Sub


    I really appreciate any help you can offer. I've been searching online for days and can't find anything that works (with my limited knowledge).

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Autofiltering then adding a value to filtered rows

    Please use code tags when posting. Refer to Forum Rule No. 3.

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-23-2014
    Location
    Charlotte, NC
    MS-Off Ver
    2010
    Posts
    4

    Re: Autofiltering then adding a value to filtered rows

    Unfortunately that isn't working right either. The first time it put an x in the first two out of an expected 4 cells. I reset the template and try again and get a "Run-time error '1004': AutoFilter method of Range class failed".

    Is there a way to use the code that I supplied but limit it to the first 500 or so rows?

    Please Login or Register  to view this content.
    My macro seems to work as I need it to except for putting x's in all the rows below 3000.

    Thanks again.

  6. #6
    Registered User
    Join Date
    06-23-2014
    Location
    Charlotte, NC
    MS-Off Ver
    2010
    Posts
    4

    Re: Autofiltering then adding a value to filtered rows

    Just figured it out.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 08-16-2012, 06:20 PM
  2. Adding different filtered columns
    By dupperco in forum Excel General
    Replies: 3
    Last Post: 06-24-2009, 03:21 AM
  3. Selecting Active Rows after autofiltering copy, pasting and deleting
    By mopatz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2008, 12:41 PM
  4. Adding only the filtered results
    By spartikus411 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-31-2006, 06:20 AM
  5. Revisiting an old topic... Autofiltering- unwanted rows!
    By James.Shanahan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2005, 06:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1