Results 1 to 3 of 3

VBA code to rearrange data into multiple columns

Threaded View

shinobi VBA code to rearrange data... 11-13-2013, 07:14 PM
ragulduy Re: VBA code to rearrange... 11-14-2013, 05:43 AM
shinobi Re: VBA code to rearrange... 11-14-2013, 06:33 AM
  1. #1
    Registered User
    Join Date
    11-10-2011
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    28

    VBA code to rearrange data into multiple columns

    Hello there,

    I have a worksheet with data arranged in descending order based on column A value. What I'm trying to do is to arrange the data into separate columns, as in the rows with the highest value in column A stay in the same place, rows with value -1 are cut and pasted to the first blank cell to the right and so on (sample workbook attached).

    I understand that this requires some kind of loop. I'd be grateful for any help.

    Sub RearrangeData()
    
    Dim LastRow as Long
    Dim FirstEmptyColumn as Long
    Dim Maximum as Byte
    
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    FirstEmptyColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column + 1
    Maximum = Range("A1").Value
    
    'I'm not sure how to put it in a loop, the bit below is wrong, I'm just trying to grasp the logic of it
    Do Until IsEmpty (Range("A:A") 
    If Range("A:C" & LastRow).Value = Maximum - 1 Then Range("A:C" & LastRow).Cut FirstEmptyColumn.Paste
    Loop
    
    End Sub
    Thanks in advance for any suggestions.

    Regards,
    shinobi
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy data from worksheet into another, rearrange columns.
    By adelkam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2013, 10:11 PM
  2. [SOLVED] How can I rearrange data in several columns?
    By amisdar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-28-2012, 10:20 PM
  3. Rearrange data from 6 columns to 1 column
    By narzio in forum Excel General
    Replies: 3
    Last Post: 03-06-2012, 02:43 AM
  4. [SOLVED] Rearrange data columns in Pivot Table
    By hedrew3 in forum Excel General
    Replies: 6
    Last Post: 01-24-2011, 05:41 AM
  5. Rearrange two columns of data
    By RexAtHighSpeed in forum Excel General
    Replies: 1
    Last Post: 12-20-2005, 04:30 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