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.
Thanks in advance for any suggestions.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
Regards,
shinobi
Bookmarks