+ Reply to Thread
Results 1 to 6 of 6

macro for deleting rows

  1. #1
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    macro for deleting rows

    Hi,

    Please help me this scenario:

    I would like to have a macro that will delete all the rows in a worksheet that contains the word "total". Please help.

    Thank you.

  2. #2
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Dorset, UK
    MS-Off Ver
    Office 2003, Office 2007
    Posts
    131

    Re: macro for deleting rows

    You can do this with a simple find in VB. First you will need to be sure that the word "Total" doesn't appear in any row that you do not want to delete. Then you need code that is something like:
    Please Login or Register  to view this content.
    Replace SheetName with the name of your worksheet.

    This deletes rows that have the word Total (not case sensitive) anywhere in any cell, including in the formulas.

    To look at final values only and ignore formulas (ie look at the answers in the cells, not the string in the formula bar), change "xlFormulas" to "xlValues".
    To only look at cells that contain nothing but the word "total", change "xlPart" to "xlWhole".
    To make the search case sensitive, change "MatchCase:=False" to "MatchCase:=True".
    Last edited by Kafrin; 06-22-2009 at 10:38 AM.

  3. #3
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    Re: macro for deleting rows

    thank you for responding. Where do i put this code and how would i run it? Pleas help. Thanks.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: macro for deleting rows

    My approach would be to put the code in a general module then create a command button (form control) in the worksheet. Assign the posted macro to the command button. Click the button and the macro fires.

    Hope this helps.

    J

  5. #5
    Forum Contributor
    Join Date
    07-22-2008
    Location
    canada
    Posts
    123

    Re: macro for deleting rows

    thanks for the idea. But the reason I would like it have as a macro so just I can press the shortcut key anytime I want and the code will run. Please help.


    Thank you.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: macro for deleting rows

    Here are a couple of links regarding assigning a macro to the keyboard.

    http://excel.tips.net/Pages/T002714_...mbination.html

    http://office.microsoft.com/en-us/ex...023061033.aspx

    Hope this helps.

    J

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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