Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-16-2016, 05:27 AM
RandWald RandWald is offline Macro to delete all rows with the word "Total" Windows 7 32bit Macro to delete all rows with the word "Total" Office 2007
Novice
Macro to delete all rows with the word "Total"
 
Join Date: Nov 2011
Posts: 6
RandWald is on a distinguished road
Default Macro to delete all rows with the word "Total"

Hi. Ofc365. Win 10. Looking for a macro to delete all rows with the word "Total" contained in text of any row in col A. I am doing a financial export from QuickBooks and I do not want my totals.


thanks, Randy
Reply With Quote
  #2  
Old 11-16-2016, 10:23 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Macro to delete all rows with the word "Total" Windows 7 64bit Macro to delete all rows with the word "Total" Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,780
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Hi
this kind of problem has been treated many times. Perhaps search the web first ?
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #3  
Old 11-23-2016, 11:51 PM
Old Old is offline Macro to delete all rows with the word "Total" Windows 10 Macro to delete all rows with the word "Total" Office 2007
Novice
 
Join Date: Nov 2016
Posts: 12
Old is on a distinguished road
Default

There are plenty of tricks you could do to get fixed. Here is one:

Go to your home tab
Go to conditional formatting
Highlight text that contains (enter the word you want)
Filter and sort
Custom Sort
Sort on cell color

Save your macro

Then all you have to do is delete the rows manually each time.
Reply With Quote
  #4  
Old 11-28-2016, 07:46 PM
rajeshn_in rajeshn_in is offline Macro to delete all rows with the word "Total" Windows 10 Macro to delete all rows with the word "Total" Office 2016
Novice
 
Join Date: Nov 2016
Posts: 3
rajeshn_in is on a distinguished road
Default

Code:
Sub Loop_Example()
    Dim Firstrow As Long
    Dim Lastrow As Long
    Dim Lrow As Long
    Dim CalcMode As Long
    Dim ViewMode As Long

    With Application
        CalcMode = .Calculation
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
    End With

    'We use the ActiveSheet but you can replace this with
    'Sheets("Sheet1")if you want
    With ActiveSheet

        'We select the sheet so we can change the window view
        .Select

        'If you are in Page Break Preview Or Page Layout view go
        'back to normal view, we do this for speed
        ViewMode = ActiveWindow.View
        ActiveWindow.View = xlNormalView

        'Turn off Page Breaks, we do this for speed
        .DisplayPageBreaks = False

        'Set the first and last row to loop through
        Firstrow = .UsedRange.Cells(1).Row
        Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

        'We loop from Lastrow to Firstrow (bottom to top)
        For Lrow = Lastrow To Firstrow Step -1

        If Application.CountIf(.Rows(Lrow), "Total") > 0 Then .Rows(Lrow).Delete = True
        Next Lrow

    End With

    ActiveWindow.View = ViewMode
    With Application
        .ScreenUpdating = True
        .Calculation = CalcMode
    End With

End Sub
Previously I use this to hide row, try it ....
Reply With Quote
  #5  
Old 11-28-2016, 07:50 PM
rajeshn_in rajeshn_in is offline Macro to delete all rows with the word "Total" Windows 10 Macro to delete all rows with the word "Total" Office 2016
Novice
 
Join Date: Nov 2016
Posts: 3
rajeshn_in is on a distinguished road
Default

Small correction

change below line
Code:
If Application.CountIf(.Rows(Lrow), "Total") > 0 Then .Rows(Lrow).Delete = True
as
Code:
If Application.CountIf(.Rows(Lrow), "Total") > 0 Then .Rows(Lrow).EntireRow.Delete
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I delete the names under "Exceptions" when I use the "Restrict Editing" feature in Word? MengS Word 0 02-25-2015 02:57 PM
remove repeated words with " macro " or " wild cards " in texts with parentheses and commas jocke321 Word VBA 2 12-10-2014 11:27 AM
Macro to delete all rows with the word "Total" Word Macro to find and delete rows that contain adjacent cells containing "." AlexanderJohnWilley Word VBA 7 11-08-2012 10:15 AM
Automated "Macro" to delete Tags/Anchors field3 Word VBA 0 02-25-2009 02:53 PM
Macro to delete all rows with the word "Total" word 2002 adding "delete" to drop down 2402RUNE Word 1 12-07-2008 09:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft