+ Reply to Thread
Results 1 to 9 of 9

Macro to move text

  1. #1
    Registered User
    Join Date
    10-14-2009
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    18

    Macro to move text

    Hello and thanks for checking this out...

    I am trying to create a macro to do the following (Microsoft Excel 2002 SP3):

    1 - Select the text from the active/selected cell (i.e. B1)
    2 - Cut the text from B1
    3 - Move to the cell directly above the active/selected cell (i.e. A1)
    4 - Add a space to the end of whatever text is in A1
    5 - Paste the contents that were cut from B1 after the text and space in A1
    6 - Delete the row where the text was cut from (i.e. entire row B)

    I have never written code for macro's before, only done recording, but just can't seem to get this sequence to work . Any help would be greatly appreciated!

    Thanks,
    Fredder
    Last edited by froffel; 10-28-2009 at 10:55 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to move text

    Perhaps like this?
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-14-2009
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Macro to move text

    Hi StephenR,

    That works perfectly!
    I appreciate you taking the time to help me.

    Many thanks,
    Fredder

  4. #4
    Registered User
    Join Date
    10-14-2009
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Macro to move text

    Hello,

    I need to take this process one step further, and was wondering if anyone knew how to make this happen. I am using the script below and it works great. However, I have a table with thousands of rows of data, and doing this manually for each row just is not efficient. So here is what I am trying to do:

    Same as below, except I need to be able to make the macro run automatically in a given worksheet by detecting the rows that are blank in column A and then run this macro accordingly in column B of that row which has been determined to be blank (as you can see, the import often cust the product description on to two rows instead of one, but I need the data all in one row to include the FULL description, which is often cut off).

    I have attached a sample spreadsheet to show the BEFORE and AFTER of what I am hoping this macro can accomplish at the push of one button.

    Would be happy to provide further clarification & details as needed. Many many thanks in advance for any help you can provide.

    Cheers,
    Fredder
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to move text

    Try this.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-14-2009
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Macro to move text

    Hi StephenR,

    Thanks so much for your reply. The macro seems to be doing something funny whereby the descriptions are duplicating themselves and not lining up properly with the part number.

    I don't think I did the best job explaining myself so its probably my fault. Let me try again in simplest terms (please refer to revise file attached):

    1 - the data will always start in A1 and be 3 colums wide, with col 1 being part number, col 2 being description, and col 3 being cost (no column titles will be included as per my previous file)

    2 - i need the macro to scan the worksheet and do the following to every row that is blank in column A:

    3 - using the attached file as an example, the macro would scan and the first empty cell in column A it would notice was A2. the macro would say move one cell to the right, to B2, take the data from B2 and add it to the data in the cell above, A2 (after adding a space to the end of the existing data in A2). Finally it would delete the now empty row B.

    4 - the macro would then carry on and do this for all remaining empty cells in column A of the worksheet

    ...hope that helps! Again, your assistance is VERY VERY much appreciated.

    Thanks,
    Fredder
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-14-2009
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Macro to move text

    Please let me know how I can better improve my chances of receiving a solution - Is my issue clearly defined?

    Thanks for your kind assistance.

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to move text

    My mistake Fredder, you explained your question perfectly well. Try this:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-14-2009
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Macro to move text

    AWESOME!!! Worked like a charm

    Thanks again for your expertise, StephenR

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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