+ Reply to Thread
Results 1 to 11 of 11

Help Needed Moving data and rows from different sheets while updating prior data.

  1. #1
    Registered User
    Join Date
    02-13-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Enterprise
    Posts
    15

    Help Needed Moving data and rows from different sheets while updating prior data.

    Version: Office 365

    What I'm trying to accomplish: I have uploaded a sample sheet to play with. None of this is the actual file just something to go off of and the types of columns I have.

    I posted in general help and then realized that maybe this isn't so general of a request. So I am posting here as it seems a better fit.

    I will attach a book and included is a copy of someone's crack at doing it with VBA. I am no expert in VBA and they are so close and I am unsure of how to modify this to make it work.

    Here is what I am trying to do:

    Everyday I paste raw data into my datasheet and there can be a lot of it. So I then have to manually go through and identify any cases that are currently being investigated on my master sheet.

    What I'm hoping for is a VBA macro that I can have as a button to update the data from my data sheet. This will save me loads of time. I have tried to do this with Vlookup and Xlookup. I have made a macro to trim all the data I don't need in the other columns and what I'm left with is basically the ones that are seen in my book.

    I am hoping to be able to click a button and run some VBA that will sift through the data for me and update my master sheet. If the service case is on the master sheet all I want it to do is look at the data sheet and replace the aging days number with the updated value. If the service case is not on the master sheet I would like for it to add the entire row to the bottom of the table as a new record. I can filter from there.


    I'm really hoping someone with much more experience than I can recognize the issue and provide a fix.

    Thanks for the help if anyone wants to attempt. I would be so grateful to have this off my plate. Also Would love to learn how it works so that I can add this to my toolbelt in other areas should they arise.

    Thanks so much for anyone willing to take a crack at this.


    ** Bonus: if marked complete the row moves off the master sheet to the completed tab and counts what shift completed it. The columns are in the table but right now I am really hoping to get the data sifted through.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    See if this is how you wanted.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-13-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Enterprise
    Posts
    15

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    This is working for the most part. What I am having trouble with now is that sometimes the script is causing the records to be duplicated several times. I am not sure why this is happening. How would I make it go back through the script and ignore anything that was already there if it is a duplicate ID? What I did to create this error is in testing I loaded some data in and then ran the script via the button. Then I changed an aging day on the datasheet to simulate the advancement of days on a record. Then went back and checked the master sheet. After running the script again by clicking the button it adds the whole file again. I have stepped through the code above with the debugger and cannot seem to figure out how to tell it to stop doing this. Any ideas as this is almost perfect.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,178

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    I tried to simulate what you did (or I think you did) using the file from post #2 by simply changing an "aging" day value. The only change on the Mater was that of the "aging Day". Data was not repeated.

    Please post the file you used and show the before/after states.
    Last edited by JohnTopley; 02-20-2022 at 03:33 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    Quote Originally Posted by Raistlin8522 View Post
    What I am having trouble with now is that sometimes the script is causing the records to be duplicated several times. I am not sure why this is happening.
    Because the code is written based on the assumption that NO duplicate within a sheet.
    If duplicate within a sheet, take only the first data.
    If not, you need to show me your desired result with the duplicates.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-13-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Enterprise
    Posts
    15

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    Quote Originally Posted by jindon View Post
    Because the code is written based on the assumption that NO duplicate within a sheet.
    If duplicate within a sheet, take only the first data.
    If not, you need to show me your desired result with the duplicates.
    Please Login or Register  to view this content.
    I think the problem is with how I am moving your code to my actual file with sensitive information inside it. Everything seems to be the same but for some reason on the file that I move the code into it is creating a duplicate each time I run the VBA to test it. I am sure that it is me doing something incorrectly. I am not very good at VBA so I am not sure how to identify the area that I am having trouble with.

    Both files have [MasterSheet]
    Both files have [DataSheet]
    Both files refer to [Table1] on master sheet.
    The only thing I see that is different are slightly different Column Names, however the values are in the same order.

    Yet when I run the code in the workbook above it runs perfectly.
    When I place the code in the actual workbook it runs well the first time. Then if I change one value [aging days] it creates duplicates of almost every row below that point and of that record.

    I am thinking that I am missing something in the use of the code or that I am not applying it to my new workbook correctly. Do the column names matter and if so how would I change that? All Columns are in the same order {Case ID} > {Age}>{Description}> {Comments}.

    Steps I took:
    I confirmed there were no duplicate case ID's.
    Then I ran the macro to update the sheet.
    Confirmed no duplicates again ( there were none at this point)
    Changed the aging days on one record from 5 to 25
    Ran the Code again and now I have two records one is at 5 days aging and the other is at 25 days aging.

    Where am I messing this up at. Id love to show the actual data but cannot. And it seems to be working in the sample workbook. This to me means that I am the issue, sadly. It is my execution that is causing this to fail. Any additional help to get this transferred over to the book correctly would be amazing. But I cannot duplicate the issue in the supplied book either. Only in the book that I move the code to, that I cannot share.

    Thank- you for all the help. Hopefully this will help someone else as well.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    If it still have duplicate after the code, column reference or data layouts would be differnt.
    So, no way to fix unless I see your workbook.

  8. #8
    Registered User
    Join Date
    02-13-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Enterprise
    Posts
    15

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    Quote Originally Posted by jindon View Post
    If it still have duplicate after the code, column reference or data layouts would be differnt.
    So, no way to fix unless I see your workbook.
    Okay here is a cleaned file. Nothing sensitive and the exact layout of the original. Hopefully you can spot what I am doing incorrectly.

    Thank you for the assistance.
    Attached Files Attached Files
    Last edited by Raistlin8522; 02-20-2022 at 06:26 PM. Reason: Incorrect file

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    You have extra headers(columns) in DataSheet with no data, so that the code replaces existing value with empty for those columns.
    Just one line change in bold.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    02-13-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Enterprise
    Posts
    15

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    Hello,

    So i was able to figure out how to fix my issue using the code provided above. Then as everything started working correctly I noticed that I needed to remove any items in my "MasterSheet" table that was not also in the "DataSheet". This would happen because the case was completed and is no longer in the report.I have been trying to figure out a way to add a step to this that will go back and check if any of the items on "MasterSheet" are no longer in the "DataSheet" and remove them. Ideally I need to figure out a way to look at Column A "service case ID" and if it is not on both sheets.. remove it from "MasterSheet" as a completed item. NOTE: the problem before was not in the code it ( it worked just as it was supposed to. It was in the way I personally had my data coming in. It was a general text not a number. I'm really hoping someone can help here

    The sheet above contains the working code and format of the tables.

    Thanks so much in advance.

  11. #11
    Registered User
    Join Date
    02-13-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Enterprise
    Posts
    15

    Re: Help Needed Moving data and rows from different sheets while updating prior data.

    Quote Originally Posted by JohnTopley View Post
    I tried to simulate what you did (or I think you did) using the file from post #2 by simply changing an "aging" day value. The only change on the Mater was that of the "aging Day". Data was not repeated.

    Please post the file you used and show the before/after states.
    Hi John,
    Sorry about not posting the resolution to my problem in a more timely manner. The issue was in the formatting. Another macro in the book was causing the ID's to be turned to text and not a number format. Once I changed that everything resolved. Now if I can figure out my next issue I should be good. Again thanks for your replies.

+ 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. Updating certain cells while moving down a row of data
    By cytochrome in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2017, 01:30 AM
  2. Moving rows of data to multiple sheets based on status for project pipeline
    By sthiessen85 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2015, 08:55 AM
  3. [SOLVED] Moving rows of data to multiple sheets based on status
    By sthiessen85 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-18-2015, 01:21 PM
  4. Replies: 4
    Last Post: 01-05-2015, 10:43 AM
  5. Replies: 0
    Last Post: 07-23-2013, 04:02 PM
  6. Automatically moving data rows to other sheets as new entires are added.
    By yehuoy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2011, 05:11 PM
  7. Replies: 4
    Last Post: 08-17-2005, 04:05 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