+ Reply to Thread
Results 1 to 6 of 6

Align CELLS in excel (to the right)

  1. #1
    Registered User
    Join Date
    06-07-2009
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    5

    Align CELLS in excel (to the right)

    Hi guys,

    I have a gigantic excel sheet based on a timescale, where the dates equal one cell each and where the start date fore the timeseries is different but the end dates are all the same.

    I need to "Shift" these cells to the right, so that all end dates are the same. The problem is that I don't know about any easy solution to do this, and to do it manually for 17k rows, well, that's gonna take some time.

    I'll try to explain what I need to do. Lets say we have cells that look like this:

    3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    8 9
    8 9
    6 7 8 9
    9
    3 4 5 6 7 8 9

    As you can see all rows start with a different "date" but all ends at the same. I would now need to shift the cells that doesn not start with 1 so they at least end with 9. The above shall look something like:

    - - 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    - - - - - - - - 8 9
    - - - - - - - - 8 9
    - - - - - - 6 7 8 9
    - - - - - - - - - 9
    - - -3 4 5 6 7 8 9

    (after posting this all spaces was deleted, so I had to use - instead to illustrate my point)

    I guess I'll have to create a macro to do it, but I was hoping there was an easier way to do it. Anyone know a good solution?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Align CELLS in excel (to the right)

    You would be better off posting a workbook with a before and after view where you manually adjust some of the data.

    I guess this is more complicated that simply right aligning the cells?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Align CELLS in excel (to the right)

    this code should do it
    Please Login or Register  to view this content.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    06-07-2009
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    5

    Thumbs down Re: Align CELLS in excel (to the right)

    Thank you for your martindwilson,

    that almost did it. Th eonly problem is that the values shall not be sorted, since they will contain actual values for each time period, they shall just be shifted to the right to make each cell represent a certain time in the time series.

    I really appreciate your help, and it would be great if you just could remove the sorting part of the code so the cells just are shifted to the right and the blanks are thus on the left side.

    Thanks,
    Johan

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Align CELLS in excel (to the right)

    andy p was right!
    try this
    Please Login or Register  to view this content.
    Last edited by martindwilson; 06-07-2009 at 01:21 PM.

  6. #6
    Registered User
    Join Date
    06-07-2009
    Location
    asd
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Align CELLS in excel (to the right)

    Thanks martindwilson,

    it worked perfectly. It took all night due to the amount of data, but it did the job!

+ 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