Results 1 to 10 of 10

Thread: Excel VBA Delete after timer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,959
    The problem arises because named ranges end up overlapping each other. Always 10 rows are being copied, but if the bottom few rows are blank, the Sheets("Cache").Cells(Rows.Count, "A").End(xlUp).Row is ignoring those when placing the next set of data on the Cache sheet.
    My suggestion is to copy only those rows down to the last cell with data in cells Q10:Q19. This helps to ensure that there is always something in column A of the Cache sheet for Sheets("Cache").Cells(Rows.Count, "A").End(xlUp).Row to work on, and thus prevent overlapping range names.

    See if the attached helps.

    While on the subject of .End(xlup), and as an aside, I see you use it often in the Hotel Booking's sheet Worksheet_Change event handler. If the data in the vicinity of D23:H32 is entered manually, it's quite likely that data will end up on the wrong rows in Q10:AB19 and below.
    Try entering a last name (column D) and press Enter, then reailise you spelt it wrongly, so go back and correct it. The problem's not confined to column D.
    What if some of the data in the vicinity of C11:C19 is missing? Blank cells will be copied, and the next .End(xlup) will return the same cell.

    It's safer not to update on the fly, but to add a button (like the ones you have) to update Q10:AB19 all at once, and not use .End(xlup) at all.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •