+ Reply to Thread
Results 1 to 7 of 7

Remove specific text rows and move to a separate sheet in a workbook

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Remove specific text rows and move to a separate sheet in a workbook

    Hello,

    I have a spreadsheet that I would like to identify a certain word string in a specific column and have those rows removed and placed in a separate labeled sheet in the same workbook

    Sample attachment:

    In the first sheet column F contains several cells that have this text "GST-P" I would like to have these rows removed from this sheet and moved to the sheet labeled "Remove GST Filing"

    Any help would be greatly appreciated

    Thank you very much

    TEST.xlsx

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Remove specific text rows and move to a separate sheet in a workbook

    Try
    Sub test()
        Application.ScreenUpdating = False
        With Sheets("gst gl").Cells(1).CurrentRegion
            .Parent.AutoFilterMode = False
            .AutoFilter 6, "gst-p*"
            If .Parent.Evaluate("subtotal(3," & .Columns("f").Address & ")") > 1 Then
                .Offset(1).Copy Sheets("remove gst filing").Cells(1)
                .Offset(1).EntireRow.Delete
            Else
                MsgBox "No data to remove"
            End If
            .AutoFilter
        End With
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Re: Remove specific text rows and move to a separate sheet in a workbook

    Thank you very much. It worked great. I added a few more filters to the code and the macro runs fine except at the end I'm getting the message "No Data to Remove" when there was data that was moved. I'm not sure how to edit this line to appear only when there is no action performed.

    Here is the revised code.....
    Thank you again.

    Sub MEALSANDENTERTAINMENT()
    Application.ScreenUpdating = False
    With Sheets("M&E").Cells(1).CurrentRegion
    .Parent.AutoFilterMode = False
    .AutoFilter 5, "Employee Expense"
    If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
    .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
    .Offset(1).EntireRow.Delete
    End If
    .AutoFilter 5, "PETTY CASH"
    If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
    .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
    .Offset(1).EntireRow.Delete
    End If
    .AutoFilter 5, "*BMO*"
    If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
    .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
    .Offset(1).EntireRow.Delete
    Else
    MsgBox "No data to remove"
    End If
    ActiveSheet.ShowAllData
    End With
    Application.ScreenUpdating = True
    End Sub
    Last edited by leebird; 10-26-2015 at 09:28 PM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Remove specific text rows and move to a separate sheet in a workbook

    ..................................
    Last edited by jindon; 10-27-2015 at 07:31 AM.

  5. #5
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Re: Remove specific text rows and move to a separate sheet in a workbook

    Thank you very much. It worked great. I added a few more filters to the code and the macro runs fine except at the end I'm getting the message "No Data to Remove" when there was data that was moved. I'm not sure how to edit this line to appear only when there is no action performed.

    Here is the revised code.....
    Thank you again.

    Sub MEALSANDENTERTAINMENT()
    Application.ScreenUpdating = False
    With Sheets("M&E").Cells(1).CurrentRegion
    .Parent.AutoFilterMode = False
    .AutoFilter 5, "Employee Expense"
    If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
    .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
    .Offset(1).EntireRow.Delete
    End If
    .AutoFilter 5, "PETTY CASH"
    If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
    .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
    .Offset(1).EntireRow.Delete
    End If
    .AutoFilter 5, "*BMO*"
    If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
    .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
    .Offset(1).EntireRow.Delete
    Else
    MsgBox "No data to remove"
    End If
    ActiveSheet.ShowAllData
    End With
    Application.ScreenUpdating = True
    End Sub

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Remove specific text rows and move to a separate sheet in a workbook

    No really sure how you want it...
    Sub MEALSANDENTERTAINMENT()
        Dim msg As String
        Application.ScreenUpdating = False
        With Sheets("M&E").Cells(1).CurrentRegion
            .Parent.AutoFilterMode = False
            .AutoFilter 5, "Employee Expense"
            If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
                .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
                .Offset(1).EntireRow.Delete
            Else
                msg = "No ""Employee Exoense"""
            End If
            .AutoFilter 5, "PETTY CASH"
            If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
                .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
                .Offset(1).EntireRow.Delete
            Else
                msg = msg & vbf & "No ""Petty Cash"""
            End If
            .AutoFilter 5, "*BMO*"
            If .Parent.Evaluate("subtotal(3," & .Columns("e").Address & ")") > 1 Then
                .Offset(1).Copy Sheets("remove Concur & BMO").Cells(1)
                .Offset(1).EntireRow.Delete
            Else
                msg = "No ""BMO"""
            End If
            ActiveSheet.ShowAllData
        End With
        If msg Then MsgBox msg
        Application.ScreenUpdating = True
    End Sub

  7. #7
    Forum Contributor
    Join Date
    08-02-2015
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    129

    Re: Remove specific text rows and move to a separate sheet in a workbook

    That's actually even better. This works great. Thank you so much.

+ 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. Count if text is in row, if so then remove value from separate sheet
    By bellamc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-10-2014, 12:52 PM
  2. How do I move multiple rows of similar into one row of data on separate sheet
    By luciedefreitas in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-04-2014, 08:00 PM
  3. Move rows with certain value to separate sheet within the workbook
    By KateM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2013, 01:14 PM
  4. [SOLVED] Move rows of data from one sheet to another based on specific values of sheet
    By buntalan80 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-26-2013, 06:21 AM
  5. Master Sheet to Open Specific Sheet from a Separate Workbook
    By jennyaccord in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2011, 10:40 AM
  6. Replies: 1
    Last Post: 12-17-2010, 03:27 PM
  7. [SOLVED] make a macro to move specific rows to another sheet
    By braxton in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-21-2005, 05:06 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