+ Reply to Thread
Results 1 to 17 of 17

Macro does not consistently paste data in the right row

  1. #1
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Macro does not consistently paste data in the right row

    Hi All,

    I'm currently having an issue with the macro I did where it will correctly paste answer selections (such as Yes/No/NA) into the right row, but it will not paste the corresponding comment into the correct row and it would always instead paste it into the 1st row. For example - 1st data entry will correctly paste everything into the 2nd row of the data tab (1st row is reserved for each item's name). 2nd entry will paste the answer selections into the 3rd row as expected, but the comments for that 2nd entry will paste the comments into their corresponding columns, but will overwrite the comments data of the 1st entry. 3rd entry will also do the same - it will correctly paste the answer selections into the 4th row, but the comments will get pasted again into the comments data in row 2, overwriting again whatever's previously listed there.

    I'm attaching the sample code here. New_Form refers to the tab of the actual worksheet, while Data refers to the data dump tab.

    Thanks in advance!
    Attached Files Attached Files
    "All your Dakar are belong to Pajero" 11 Dakar Rally wins...7 straight since 2001.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Macro does not consistently paste data in the right row

    Could you attach a copy of your file? Explain in detail what you want to do using a few examples from your data and referring to specific cells, rows, columns and sheets. De-sensitize the data if necessary.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    365
    Posts
    199

    Re: Macro does not consistently paste data in the right row

    Please attach your workbook instead This will be difficult without it!

  4. #4
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Re: Macro does not consistently paste data in the right row

    Apologies to all. Attaching a de-sensitized version of the sheet. Don't mind the dropdowns on some.

    Thank you again.
    Attached Files Attached Files

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Macro does not consistently paste data in the right row

    The copy of the file you posted has no data so it is hard to test a possible solution. Also, you want to copy data from Columns J and K and cell I2 but these don't have any data either. Could you post a copy of your file that includes the data to make it easier to test a macro?

  6. #6
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Re: Macro does not consistently paste data in the right row

    Uploading an updated attachment.

    Going to the data tab, row 4 is scoring for the 1st evaluation (call ID 123456789), row 5 is the scoring for the 2nd evaluation (call ID 987654321). The behavior is that the scores for the 2nd eval is saved correctly to the correct row, but the comments for the 2nd eval gets saved where the comments for the 1st eval is.

    New_Form (2) is the duplicated 2nd eval to show the comments and the comments in the data tab was saved in the wrong row.

    Thanks.
    Attached Files Attached Files

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Macro does not consistently paste data in the right row

    Try:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Re: Macro does not consistently paste data in the right row

    awesome, works perfectly. Thank you so much, highly appreciated!

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Macro does not consistently paste data in the right row

    You are very welcome.

  10. #10
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Re: Macro does not consistently paste data in the right row

    Apologies on the thread necromancy, but I just added a few rows to the New_Form tab and made the appropriate mapping changes on the macro, and while that's already done, it now overwrites the info saved to the Data tab.

    For example, eval 1 should save in row 4 of the Data tab as that's the 1st blank row, and eval 2 should save in row 5. That was the old behavior but post-update, it just keeps overwriting the data in row 4.

    I've already copied and pasted Mumps' macro above but to no avail.

    Anything I might have missed out or accidentally deleted?

    Thanks!

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Macro does not consistently paste data in the right row

    It would probably help if you posted the changed code. Best guess would be that you're using the wrong column to find the output row.
    Everyone who confuses correlation and causation ends up dead.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Macro does not consistently paste data in the right row

    Please attach a copy of your updated file.

  13. #13
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Re: Macro does not consistently paste data in the right row

    Apologies, here's the file.

    Thanks!

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Macro does not consistently paste data in the right row

    You appear to be copying a lot more rows from some columns than others. Since the code uses column A to determine the next blank row, and column A is not the most populated column, you will naturally end up overwriting data. Use a different column.

  15. #15
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Re: Macro does not consistently paste data in the right row

    hi rorya: let me check that again since i'm sure that issue of copying more columns is already okay. the problem is it keeps overwriting existing rows in the raw data's tab. so instead of me having a running raw data starting from row 4 up to how many I've done, it just keeps overwriting data that's already on row 4.

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: Macro does not consistently paste data in the right row

    That's what I'm saying. Your code copies about 10 rows from column E to column A, but it copies a lot more rows from some of the other columns, meaning column A on the data sheet is blank for those additional rows. The code uses column A to determine the next blank row, which then means you get data overwritten. You need to either use the column you copy most rows from to determine the next blank row, or use a loop (or Find operation) and find the last populated row on the data sheet.

  17. #17
    Registered User
    Join Date
    05-03-2007
    MS-Off Ver
    2016
    Posts
    38

    Re: Macro does not consistently paste data in the right row

    i redid the mapping and now it works. thanks!

+ 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. Need help with macro - opens some links [consistently] twice
    By tiwas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-07-2018, 02:17 PM
  2. Macro to subtotalize using Sumproduct(Sumifs()) won't work consistently
    By takeshi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-17-2018, 06:31 PM
  3. de-identifying data consistently across multiple files
    By imsicau in forum Excel General
    Replies: 1
    Last Post: 09-25-2015, 09:25 AM
  4. Macro Project - Consistently breaks
    By dkatz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2015, 04:02 PM
  5. Import Data from a website consistently
    By edneco in forum Excel - New Users/Basics
    Replies: 11
    Last Post: 11-19-2013, 07:28 PM
  6. Macro doesn't work consistently
    By mrbill11 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2012, 04:35 PM
  7. Data in Excel is not wrapping within cell consistently
    By Bronwyn in forum Excel General
    Replies: 0
    Last Post: 03-29-2005, 10:06 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