+ Reply to Thread
Results 1 to 10 of 10

Recording Macro that deletes remaining columns

  1. #1
    Registered User
    Join Date
    03-13-2014
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Recording Macro that deletes remaining columns

    I am trying to record a macro that leaves me with only those rows that I wish to work with. The sample I'm attaching has been dummied to only 100 rows, but my real worksheet has around 25,000 rows and 76 columns at any given time. What I'm trying to accomplish overall is this:

    Delete all rows that have a blank in column C: Docs to County.
    Delete all rows that have "Electronic Transmission" in column D: Tracking Number
    Delete all rows that have a blank in column E: Docs Received from County.
    Delete all rows that have a blank in column F: Recorded Date.

    I'm fairly inexperienced, so I've been trying to record a macro that would get to the end result as if I were filtering the spreadsheet myself, which would be filter down to the blanks in each column and then delete all of the remaining rows, but this doesn't seem to work when recording a macro because I have too many continuous something... I don't remember the exact wording from the error I received. I'd welcome any feedback or further recommendations for streamlining this process.
    Attached Files Attached Files
    Last edited by shawnnai; 12-14-2015 at 04:27 PM. Reason: typed in incorrect requirements for final result

  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: Recording Macro that deletes remaining columns

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-13-2014
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Recording Macro that deletes remaining columns

    Thank you - I plugged this in exactly as it is, but I got a bug here:
    Range(Cells(2, i), Cells(x, i)).SpecialCells(4).EntireRow.Delete

  4. #4
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Recording Macro that deletes remaining columns

    Please Login or Register  to view this content.

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

    Re: Recording Macro that deletes remaining columns

    Can you provide a sample sheet with some dummy data which produces the error? BTW what does the error say?

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

    Re: Recording Macro that deletes remaining columns

    Sorry I misread your requirements.

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 12-08-2015 at 04:19 PM.

  7. #7
    Registered User
    Join Date
    03-13-2014
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Recording Macro that deletes remaining columns

    @rcm - This is great! Except I think I asked incorrectly the first time. I want to delete all rows with blanks from Column C and KEEP all rows with blanks for Columns E & F, so what do I enter for the value to delete everything EXCEPT blanks for those?

  8. #8
    Registered User
    Join Date
    03-13-2014
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Recording Macro that deletes remaining columns

    @John H Davis - when I ran this last code on my spreadsheet, the report returned with 7 rows, four of which show a Tracking Number "Electronic Transmission."

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

    Re: Recording Macro that deletes remaining columns

    Quote Originally Posted by shawnnai View Post
    @John H Davis - when I ran this last code on my spreadsheet, the report returned with 7 rows, four of which show a Tracking Number "Electronic Transmission."
    Note: the code was edited at 3:19 EST. your test file has "ElectronicTransmission". Also what I found is when I tried to meet your requirements there were no rows?

  10. #10
    Registered User
    Join Date
    03-13-2014
    Location
    Omaha, NE
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Recording Macro that deletes remaining columns

    Quote Originally Posted by JOHN H. DAVIS View Post
    Note: the code was edited at 3:19 EST. your test file has "ElectronicTransmission". Also what I found is when I tried to meet your requirements there were no rows?
    Yes - I put them in incorrectly. What I do actually need is:
    Delete all rows that have a blank in column C: Docs to County.
    Delete all rows that have "ElectronicTransmission" in column D: Tracking Number
    Delete all rows that DO NOT have a blank in column E: Docs Received from County.
    Delete all rows that DO NOT have a blank in column F: Recorded Date.

+ 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. Need help with macro that deletes all columns, except ones with certain headers
    By pavlovs2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2015, 03:15 PM
  2. Macro to filter 2 columns and then delete remaining rows
    By jimmisavage in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-12-2014, 11:01 AM
  3. Recording Macro is deleting all columns instead of just one
    By Elizabethd1012 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-19-2014, 02:11 PM
  4. Replies: 2
    Last Post: 02-11-2014, 05:05 AM
  5. [SOLVED] cut the cells to 3 columns in excel & remaining columns should be added to the next row
    By kr61665 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-06-2013, 11:07 AM
  6. Deletes certain columns
    By T De Villiers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2006, 07:15 AM
  7. Macro That Deletes Columns
    By Lilbit in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2006, 12:25 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