+ Reply to Thread
Results 1 to 7 of 7

Code to copy from one sheet to other not working properly

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Code to copy from one sheet to other not working properly

    Hi I have below code which was brilliant help from Mumps1 in this forum. What i did not think about was that it has to be changed to the need in the real worksheet. I thought i could do easily, but it dont work-.
    The code i got compare a number in column B sheet2 with column B in sheet3 , if there is a match it overwrite the row in Sheet3. If there is a new number in sheet2 column B the it add this row to the last last used row in sheet 3. All good and the code was working. And fast also which is important- In the test sheet there was 6 columns, but in the real sheet there is columns from A to AJ all if i count correctly 37 columns.
    I have tried change below code to the amount of columns but it dont work. It will not copy all the columns mostly just the same 5 as before.

    First is the code Mumps1 helped me with work fine for column A to F
    And after that the code i tried but not working.

    I have attached a test sheet with all columns now.
    So if time please have a look thanks.
    Sincerely
    Abjac

    Please Login or Register  to view this content.
    And this is what i tried but not working,

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

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Code to copy from one sheet to other not working properly

    Your code works for me, what is not working for you?
    Column AJ is column 36

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

    Re: Code to copy from one sheet to other not working properly

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    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.

  4. #4
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Code to copy from one sheet to other not working properly

    Hi davesexcel. The code i provided did not copy if there was a change in the cells in sheet2 not after column E-
    Mumps1. You did it again. The code is with the little change work perfectly. So thanks alot. I will mark it as solved. But would be nice if you could
    explain what these numbers do and refer to example Item:=i + 6. Because to be honest dont really understand it totally. When i tried change the code. I had doubt about this. But thanks allot really great help again.
    Sincerely
    abjac

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

    Re: Code to copy from one sheet to other not working properly

    Please Login or Register  to view this content.
    Each unique value in column B of Sheet2 is stored in rngList as the Key and the Item stores the row number for each value. Since your data starts in row 7, the row number would be calculated by adding 6 to the value of "i". If "i" is 1 then the row number is i + 6 which calculates to 7 and so on. This row number is then used to paste the data in the correct row in Sheet3. I hope this makes sense.

  6. #6
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102
    Quote Originally Posted by Mumps1 View Post
    Please Login or Register  to view this content.
    Each unique value in column B of Sheet2 is stored in rngList as the Key and the Item stores the row number for each value. Since your data starts in row 7, the row number would be calculated by adding 6 to the value of "i". If "i" is 1 then the row number is i + 6 which calculates to 7 and so on. This row number is then used to paste the data in the correct row in Sheet3. I hope this makes sense.
    HI yes I understand this now. Which is good way. The code is fast. Thanks for the explanation and help
    Sincerely
    abjac

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

    Re: Code to copy from one sheet to other not working properly

    My pleasure.

+ 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: 5
    Last Post: 03-03-2018, 01:16 AM
  2. My VBA code stopped working properly
    By Dark0Prince in forum Excel General
    Replies: 22
    Last Post: 02-07-2017, 01:16 PM
  3. [SOLVED] Find code not working properly
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2014, 06:36 AM
  4. Code NOT working properly - Copy/Paste Multiple Tables
    By Blackhawks in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-14-2014, 12:18 PM
  5. Sheet Selection VBA Code is not working properly
    By robrobet in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-10-2014, 12:39 PM
  6. [SOLVED] Code not working properly
    By TomRet in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-01-2014, 04:16 AM
  7. Help with figuring out some code (not working properly)
    By andyd2k in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2005, 07: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