+ Reply to Thread
Results 1 to 7 of 7

Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

  1. #1
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

    Good evening. I'm using the following code to delete select rows one at a time. I need the last row in the range to remain therefore I prevented the user from deleting the row one up from the row that contains "Total Hours" (which is always in Column B). The code works great as long at the user clicks into a cell in column B. If the user clicks into a cell in column A, C, D, E, F, G, H, or I then the code allows the user to delete the last row.

    I believe I need to search entire rows to determine if the row contains "Total Hours" but I can't figure out how to accomplish this feat. Your assistance would be appreciated. Thanks.

    Please Login or Register  to view this content.
    Matthew
    Attached Files Attached Files

  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: Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

    How about this?:

    Please Login or Register  to view this content.
    _________________
    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
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

    JB,

    Thanks for chiming in. I gave it a whirl and no dice. In the event I placed your suggestion into my code incorrectly, here's where I placed it (see below).

    Please Login or Register  to view this content.
    Matthew

  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: Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

    Hi Matthew

    If your Code otherwise works try this
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

    John,

    The additional lines of code work great to limit the user to column B. I've got an odd behavior occurring that I did not detect in my previous trials. When I select a row to delete in one range a row in the range below the range I've selected deletes. Ugh. Off to problem solve. Thanks for pointing me in the right direction with regards to the code you provided.

    Matthew

  6. #6
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

    John,

    I figured out what is happening. The cell that was selected BEFORE clicking the Delete Client command button is the cell that is deleting and not the cell that is being selected AFTER the Delete Client command button is clicked. Here's what I've come up with and it seems to be working okay now. Thanks again.

    Matthew

    Please Login or Register  to view this content.

  7. #7
    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: Find "Total Hours" by searching entire rows below selected cell vs. cells in a column

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ 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. Replies: 3
    Last Post: 04-14-2013, 11:53 PM
  2. Pulling an entire Column "IF" a cell contains "x"
    By jdskin2 in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2012, 01:31 PM
  3. [SOLVED] Macro to delete entire row if cell contains the word "total" or "Total"
    By theatricalveggie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2011, 12:38 PM
  4. Find all cells with "A" and add the values of the adjacent cell to give a total.
    By leefarrell in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2006, 11:09 AM

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