+ Reply to Thread
Results 1 to 12 of 12

Not sure why the rows are overwritten???

  1. #1
    Registered User
    Join Date
    04-30-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Not sure why the rows are overwritten???

    I have found the following code on here and it does nearly what i want but i need to make some mods but have no idea how????
    bascally this code looks at the text in Cell 11 and if it says "complete" moves the entire row to another work sheet labelled "completed".
    My problem is that it seems to place the cut row on any row in the completed sheet not the next avalible line???
    Additionally i would like to add a date to the rows that are moved ???

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim LR As Long
    If Target.Count > 1 Then Exit Sub
    If Target.Column = 11 And LCase(Target.Value) = "complete" Then
    Application.EnableEvents = False
    With Sheets("completed")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    Target.EntireRow.Copy Destination:=.Range("A" & LR + 1)
    Target.EntireRow.Delete
    Application.CutCopyMode = False
    Application.EnableEvents = True
    End With
    End If
    End Sub

  2. #2
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Not sure why the rows are overwritten???

    Hi,
    just tested and it does what it should = copy source to next available line (my 'completed' sheet was clear).
    for example: When you want to place a date before the coppied line, do not copy entire row, but only a range and paste to completed.range("B" & LR+1) and you can enter a date to completed.range("A" & LR+1) after that.

  3. #3
    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: Not sure why the rows are overwritten???

    Hi orammer

    Welcome to the Forum!!

    Please add Code Tags to your Code...

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    With regard to your issue...you may have extraneous Data below your expected last row. Delete all the Cells below your expected last row and try again.
    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.

  4. #4
    Registered User
    Join Date
    04-30-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Not sure why the rows are overwritten???

    I have tried but failed to find the problem???
    Every time i complete another row, it moves to the second tab but overwrites what was there so its a bit of a mystery.
    Im trying to build a history of all the completed lines
    Any other ideas??

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Not sure why the rows are overwritten???

    As already requested, please add Code Tags to your post.

    Please post a sample workbook with ant sensitive data replaced by boiler plate text so we can see the typical content and structure of the data.

    Your code may work well given the right data layout ... as Miroslav R. has demonstrated.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Registered User
    Join Date
    04-30-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Not sure why the rows are overwritten???

    My appologies i hope i have the tag in the right place
    I will upload a copy of the spreadsheet

    Please Login or Register  to view this content.
    Last edited by ohrammer; 07-08-2014 at 06:33 AM.

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

    Re: Not sure why the rows are overwritten???

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the post window:

    Please Login or Register  to view this content.
    ... and appear like this when posted:

    [Select Code] copy to clipboard

    your code here ...
    and here ...
    and here

    You can also type the code tags in manually if you prefer. For more information about these and other tags, click here.

  8. #8
    Registered User
    Join Date
    04-30-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Not sure why the rows are overwritten???

    meeting minutes test.xlsm

    my spreadsheet when items get completed in colum D the row should move to the completed tab

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Not sure why the rows are overwritten???

    Please Login or Register  to view this content.

    You were using column A to determine the next available row. But there was nothing in column A, hence it overwrites the data already there.

    Regards, TMS

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Not sure why the rows are overwritten???

    PS: moral of the story ... if you post a sample workbook at the outset, the problem will get fixed quicker.

    Oh, and you're not actually using the LR variable, hence I have commented it out here.

    Regards, TMS

  11. #11
    Registered User
    Join Date
    04-30-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Not sure why the rows are overwritten???

    Thanks for your help

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Not sure why the rows are overwritten???

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. Recovering overwritten file
    By Bostrolicious in forum Excel General
    Replies: 4
    Last Post: 07-13-2014, 11:37 PM
  2. VBA Code Help - If file overwritten, continue. If file not overwritten, show warning.
    By spoliquin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2013, 05:03 PM
  3. how to do that the date would not be overwritten
    By soulfriend in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2011, 05:34 PM
  4. overwritten file
    By jap786 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-03-2006, 11:10 AM
  5. [SOLVED] Recovering An Overwritten File
    By Need To Recover A Spreadsheet in forum Excel General
    Replies: 1
    Last Post: 07-21-2005, 12:05 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