+ Reply to Thread
Results 1 to 4 of 4

Looking to delete all rows down to a particular cell value

  1. #1
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Looking to delete all rows down to a particular cell value

    Im looking to use a macro to delete the first few rows of a file, down to where 'Line' is listed as the cell value. It will always appear in Column A, but can vary between Rows 8-10. The below code deletes a fixed number of rows (9), but it needs to be flexible, should 'Line' appear in row 8 or 10. Any assitance would be greatly appreciated.

    Please Login or Register  to view this content.
    Thanks,
    Ray

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking to delete all rows down to a particular cell value

    This is how I would do that:
    Please Login or Register  to view this content.
    I really want to draw your attention to the red lines, when you record a macro, it records your human actions of selecting and activating. You'll need to start editing those multiple lines of code down to single fully formatted commands, selecting is only necessary if you're a human. VBA can simply "do it" if the command is complete.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-31-2013
    Location
    Golden, CO
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Looking to delete all rows down to a particular cell value

    I greatly appreciate your quick response JB. This code works great except that it deletes the row that has the cell value 'Line', I need this to be my first row. My apologies if that was unclear.

    Thanks,
    Ray

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking to delete all rows down to a particular cell value

    So vFIND.Row becomes vFIND.Row - 1

+ 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. [SOLVED] Find row cell containing specific text, then delete all rows ABOVE that cell
    By ks100 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2013, 02:02 PM
  2. [SOLVED] Delete rows if any cell in Sheet 1 rows matches any cell in Sheet2 column
    By newbie88 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2012, 10:26 AM
  3. Delete Rows by Cell Value - Delete sheets w/out prompt
    By Jimmydageek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2010, 02:03 PM
  4. Delete rows where active cell is selected without hardcoding cell
    By alexfortin in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-19-2009, 06:58 PM
  5. Delete Rows based on cell value and then Insert rows alternatively with a formula
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-11-2008, 04:27 PM

Tags for this Thread

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