+ Reply to Thread
Results 1 to 3 of 3

Delete Table Rows of filtered data - when some columns are hidden

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Delete Table Rows of filtered data - when some columns are hidden

    Just trying to delete the red rows here... some columns are hidden though which I think is what is giving me the problem - due to the visible cells reference...

    Id guess I just have to say visible cells, rows, but ive been trying for a while and am just not getting it haha...... what am I doing wrong here - see attached

    Thank you for any help!


    Here are 2 of the recent ones ive tried.. although theres been like 6-7 variations..

    Sub ClearClosedFiles()
        Dim wb As Workbook
        Set wb = ThisWorkbook
            With wb.ActiveSheet.ListObjects("Table_WorkloadTracking")
                .Range.AutoFilter Field:=5, Criteria1:=RGB(192, 0, 0), Operator:=xlFilterCellColor
                Rowz = .Range.Columns(2).SpecialCells(xlCellTypeVisible).Cells.Count - 1
                If Rowz > 0 Then Range("Table_WorkloadTracking[FileNo]").Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
                .ShowAllData
            End With
    End Sub
    
    Sub ClearClosedFiles2()
        ActiveSheet.ListObjects("Table_WorkloadTracking").Range.AutoFilter Field:=5, Criteria1:=RGB(192, 0, 0), Operator:=xlFilterCellColor
        Rowz = ActiveSheet.ListObjects("Table_WorkloadTracking").Range.Columns(5).SpecialCells(xlCellTypeVisible).Cells.Count - 1
            If Rowz > 0 Then
                rng = ActiveSheet.ListObjects("Table_WorkloadTracking").DataBodyRange.Address
                ActiveSheet.Range(rng).SpecialCells(xlCellTypeVisible).EntireRow.Delete
            End If
        Range("Table_CollPreComplaint2[[#Headers],[FileNo]]").Select
        ActiveSheet.ShowAllData
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Delete Table Rows of filtered data - when some columns are hidden

    So this is halfway there... 2 problems with it though --- 1, the blank rows 1-4 are being removed and 2, its throwing an error..... i put an on error resume in there just to see if it works..

    can anyone fill in the blanks here maybe?

    Sub ClearClosedFiles()
    Dim lRows As Long
    On Error Resume Next
        Application.Calculation = xlCalculationManual
        ActiveSheet.ListObjects("Table_WorkloadTracking").Range.AutoFilter Field:=5, Criteria1:=RGB(192, 0, 0), Operator:=xlFilterCellColor
            For lRows = ActiveSheet.Range("Table_WorkloadTracking[FileNo]").Rows.Count To 1 Step -1
                If Cells(lRows, 2).EntireRow.Hidden = False Then Rows(lRows).EntireRow.Delete
            Next lRows
        Range("Table_WorkloadTracking[[#Headers],[FileNo]]").Select
        ActiveSheet.ShowAllData
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-08-2015
    Location
    North Carolina USA
    MS-Off Ver
    MS Office 2016
    Posts
    368

    Re: Delete Table Rows of filtered data - when some columns are hidden

    Got ittt... thanks to everyone for the help! haha

    Sub ClearClosedFiles()
    Dim lRows As Long
    On Error Resume Next
    On Error Resume Next
        Application.Calculation = xlCalculationManual
        ActiveSheet.ListObjects("Table_WorkloadTracking").Range.AutoFilter Field:=5, Criteria1:=RGB(192, 0, 0), Operator:=xlFilterCellColor
            For lRows = ActiveSheet.Range("Table_WorkloadTracking[FileNo]").Rows.Count To 5 Step -1
                If Cells(lRows, 2).EntireRow.Hidden = False Then Rows(lRows).EntireRow.Delete
            Next lRows
        Range("Table_WorkloadTracking[[#Headers],[FileNo]]").Select
        ActiveSheet.ShowAllData
    End Sub

+ 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: 10
    Last Post: 06-07-2018, 04:16 PM
  2. Replies: 4
    Last Post: 09-15-2016, 11:57 AM
  3. [SOLVED] Can you delete filtered rows in a table?
    By Butcher1 in forum Excel General
    Replies: 2
    Last Post: 02-25-2015, 01:01 PM
  4. Replies: 1
    Last Post: 04-08-2014, 02:50 AM
  5. Chart showing filtered rows bot not hidden columns?
    By D-smoke in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-01-2012, 05:53 AM
  6. copying filtered data WITH the hidden columns
    By noraaa in forum Excel General
    Replies: 2
    Last Post: 07-04-2012, 04:28 AM
  7. Replies: 4
    Last Post: 06-11-2010, 03:29 PM

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