+ Reply to Thread
Results 1 to 4 of 4

Code deletes HEADER Row

  1. #1
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    Code deletes HEADER Row

    A code is designed to delete rows by a certain phrase. It works great so as long rows under the header row has data. If the row(s) under the header row does not have any data (some scenarios call for no data), it will execute the routine and ALSO delete the header row. How can the code be adjusted for this scenario?

    See attached file sample:

    Data Dump = with data. If you run code, it works fine.

    Data Dump 2 = no data. If you run code, header is deleted as well. I need rows C5 and before to not be deleted...


    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code deletes HEADER Row

    If there's no data then .Cells(Rows.Count, "H").End(xlUp).Row will return 5, the header row.

    Add a check to make sure the delete part of the code doesn't run if that is the case.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-15-2006
    Location
    USA
    MS-Off Ver
    Office 365, 64 bit
    Posts
    371

    Re: Code deletes HEADER Row

    Norie -

    Can you recommend a check in case of no data? I'm stuck there...Thanks.

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Code deletes HEADER Row

    try this:
    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

+ 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