+ Reply to Thread
Results 1 to 11 of 11

Macro to Move Data into Another Column

  1. #1
    Registered User
    Join Date
    09-21-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    81

    Macro to Move Data into Another Column

    Hello all,

    Trying to write a macro that will move data from one column into another column based on the headers in row 1. I have two columns (RNotes and GNotes). These columns are not always next to each other, which is why I’d like to use the header in row 1 to identify. The data in GNotes needs to move into RNotes separated by a space.

    In the attached example, the data in GNotes moves into RNotes and notes1 and Notes2 are separated by a space in the cell in the RNotes column.


    Help is appreciated - thank you!

    Question also posed at MrExcel: http://www.mrexcel.com/forum/showthread.php?t=536933
    Attached Files Attached Files
    Last edited by MSmithson; 03-17-2011 at 08:08 PM.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Move Data into Another Column

    Msmithson,

    It does not matter what columns the following headings are in RNotes RNotes, as long as they are in row 1, then the macro will move the data per your request.

    Detach/open workbook FindMoveData - Msmithson - EF768723 - SDG12.xls and run macro FindMoveData.



    To test the macro in another workbook:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Then run the FindMoveData macro.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    09-21-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: Macro to Move Data into Another Column

    That worked! Thanks stanleydgromjr!

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Macro to Move Data into Another Column

    Here is the macro and the file to do it.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    09-21-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: Macro to Move Data into Another Column

    Hi stanleydgromjr,

    Is there a way to amend the code to keep the formatting of the text in the GNotes column after it moves over? The text in GNotes is highlighted in red and I'd like to keep it highlighted when it moves over into RNotes. The text in RNotes is black (and I'd keep it that way so I can see the difference between the notes when they are merged together). I tried using a .Text command for your macro instead of a .Value, but that did not work.

    Any suggestions would be helpful - thanks!

  6. #6
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Move Data into Another Column

    Msmithson,

    Please attach another workbook that displays your raw data correctly, with formatting, and include before and after worksheets.

  7. #7
    Registered User
    Join Date
    09-21-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: Macro to Move Data into Another Column

    Attached is an example for the macro. Thank you!
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Macro to Move Data into Another Column

    Msmithson,

    Detach/open workbook FindMoveData - Msmithson - EF768723 - V2 - SDG12.xls and run macro FindMoveDataV2.

  9. #9
    Registered User
    Join Date
    09-21-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    81

    Re: Macro to Move Data into Another Column

    Thanks stanleydgromjr - that worked perfectly!

  10. #10
    Registered User
    Join Date
    06-22-2011
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Macro to Move Data into Another Column

    I have an issue where I am trying to combine all the data in row into columns where the header in row 1 is the same.

    Member Name, Name, Etc

    Basically I need to turn this into a csv where all the data from each header is in the list in the appropiate column.

    It is business contact info so the rows have to contain all the data for the accurate client.

    Not all of the "accounts" have all of the same headers so I want it to just grab data from "Name" Address, phone number, etc and put it in the name column and the next header with it. etc so I have 1 row for each header and all the data in the rows below it.

    Seems difficult but, you guys can do anything from what I read here :-)

    Edward
    Attached Files Attached Files
    Last edited by killerkarny; 06-22-2011 at 02:18 AM.

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,265

    Re: Macro to Move Data into Another Column

    Hi and welcome to the forum.

    Unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
    Remember what the dormouse said
    Feed your head

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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