+ Reply to Thread
Results 1 to 10 of 10

Move Macro

  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    15

    Question Move Macro

    Hey guys I am working on an excel sheet which contains several thousand rows of data but every 19th row the data is in the wrong row and column and I need to move it up one row and right one column.

    I have started to do this manually but i was wondering if it was possible if a macro could do this for me.

    Thanks for your help

    Alan

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Move Macro

    You don't say what column or what else is in the other rows. Assuming that you have free rein, with a formula:

    E1: =IF(MOD(ROW(),18)=0,D2,"") and copy down

    Adjust the column as required.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-09-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: Move Macro

    Hey TMS thanks for the reply, sorry forgot to mention what i was working with, the column b is a combination of date and time fields which i will be separating on another date.

    The data in every 19th row will be a time field each time being different from the last. the reason why it displays gets separated from the time field is because the data is converted from pdf documents and the formatting of the documents converts this way.

    As i'm new will i have to change the =0 to anything specific to represent a time value.

    If you want i can post a sample of what i'm working with.

    Thanks

    Alan

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Move Macro

    Yes, please post a small sample workbook ... With at least 38 rows of data to play with.


    Regards, TMS

  5. #5
    Registered User
    Join Date
    04-09-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: Move Macro

    Hey TMS

    This is a small bit of how all the pdf documents that i will be working with will convert the data to excel.

    Thanks

    Alan
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Move Macro

    I'll get back to you later (this afternoon). Just about to board a plane but I have a revised formula and I'll put it into a VBA routine when I get home.

    Regards, TMS

  7. #7
    Registered User
    Join Date
    04-09-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: Move Macro

    Really appreciate than thank you for all your help.

    Regards Alan

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Move Macro

    OK, the formula in cell C1 and copied down to the last row of data is:

    =IF(B1="","",IF(--B1<1,"",IF(--B2<1,--B1+--B2,--B1)))

    You then need to format the cells in column C as Date/Time and convert the formulas to values (or vice-versa). At that point, you can delete the original column B.



    A VBA module to do all that is shown below:

    Please Login or Register  to view this content.

    Please see the attached updated sample workbook.


    Regards, TMS
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-09-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: Move Macro

    Hey

    Just tested that work works like a charm.

    Legend gonna make it so much easier to sort out all those pdf's.

    Thanks Again

    Alan

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Move Macro

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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