+ Reply to Thread
Results 1 to 15 of 15

VBA code to move data in columns by ID in a different column

  1. #1
    Registered User
    Join Date
    03-29-2007
    MS-Off Ver
    365
    Posts
    70

    VBA code to move data in columns by ID in a different column

    Hi all,

    I have an Excel workbook with ID number in Column A. The same ID can repeat. There are other data in Column C, D and E. I am looking for a VBA code to move data in Column C, D E to the top row of each ID.

    like the photo attached.

    Excel.jpg

    appreciate any help and suggestion. Thank you so much.
    Last edited by tt388; 05-11-2024 at 08:36 PM.

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

    Re: VBA code to move data in columns by ID in a different column

    Try:
    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.

  3. #3
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: VBA code to move data in columns by ID in a different column

    Please Login or Register  to view this content.
    Last edited by daboho; 05-10-2024 at 10:53 PM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

  4. #4
    Registered User
    Join Date
    03-29-2007
    MS-Off Ver
    365
    Posts
    70

    Re: VBA code to move data in columns by ID in a different column

    Thanks #2 and #3 for your help !

  5. #5
    Registered User
    Join Date
    03-29-2007
    MS-Off Ver
    365
    Posts
    70

    Re: VBA code to move data in columns by ID in a different column

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.



    This code worked well for my spreadsheet.


    There are additional scenarios in my use case.

    1. Additional columns to move (ie. Column E, F, G....)
    2. If there are no data in column C, D but E

    Thank you so much for your help!
    Last edited by tt388; 05-10-2024 at 10:00 PM.

  6. #6
    Registered User
    Join Date
    03-29-2007
    MS-Off Ver
    365
    Posts
    70

    Re: VBA code to move data in columns by ID in a different column

    Quote Originally Posted by daboho View Post
    Please Login or Register  to view this content.

    Thank you so much for your help, but the codes did not seem to work as the data did not move.

  7. #7
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: VBA code to move data in columns by ID in a different column

    try this only sort
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by daboho; 05-10-2024 at 11:11 PM.

  8. #8
    Registered User
    Join Date
    03-29-2007
    MS-Off Ver
    365
    Posts
    70

    Re: VBA code to move data in columns by ID in a different column

    Quote Originally Posted by daboho View Post
    try this only sort
    Please Login or Register  to view this content.
    Thanks again, but a Run time error / Automation error was returned on
    Set v = CreateObject("System.collections.sortedlist")

  9. #9
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: VBA code to move data in columns by ID in a different column

    maybe you using option explicit,try again i has update code and workbook in post #7
    Last edited by daboho; 05-10-2024 at 11:12 PM.

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

    Re: VBA code to move data in columns by ID in a different column

    Please Login or Register  to view this content.
    Last edited by jindon; 05-11-2024 at 07:50 AM.

  11. #11
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: VBA code to move data in columns by ID in a different column

    for dinamic moving area, only change starCol from star col number to moving change 3 to your number col
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by daboho; 05-11-2024 at 05:45 AM.

  12. #12
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,016

    Re: VBA code to move data in columns by ID in a different column

    There are additional scenarios in my use case.

    1. Additional columns to move (ie. Column E, F, G....)
    2. If there are no data in column C, D but E
    Another option to try:
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-29-2007
    MS-Off Ver
    365
    Posts
    70

    Re: VBA code to move data in columns by ID in a different column

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    This works perfectly. Thank you so much for your assistance !!

  14. #14
    Registered User
    Join Date
    03-29-2007
    MS-Off Ver
    365
    Posts
    70

    Re: VBA code to move data in columns by ID in a different column

    Quote Originally Posted by Akuini View Post
    Another option to try:
    Please Login or Register  to view this content.

    This works the best and it can be customized easily ! Thank you so much for your input !

  15. #15
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,016

    Re: VBA code to move data in columns by ID in a different column

    You're welcome, glad we could help

+ 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: 0
    Last Post: 01-12-2024, 11:01 AM
  2. Move Data from Columns on Different Sheets to one column
    By irajeev in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-24-2016, 08:14 PM
  3. Replies: 12
    Last Post: 03-14-2016, 08:42 AM
  4. [SOLVED] Convert column B as multiple column titles and move data in column C into new columns?
    By princesscathryn in forum Excel - New Users/Basics
    Replies: 8
    Last Post: 06-30-2014, 07:31 PM
  5. [SOLVED] Move data from Column A-E or B-F to columns G-K
    By netnewbie in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 10-01-2013, 10:05 AM
  6. [SOLVED] How to move one Column's data to other Columns...
    By LeoThe Lion in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-25-2012, 05:11 AM
  7. Move Data from one column to many columns
    By Barb in forum Excel General
    Replies: 3
    Last Post: 01-16-2006, 01:00 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