I have large table with columns of dates : 1 january, 2 january, 3 january ...
But now it's crucial not to scroll right cause of big data.
My idea is to invert columns:27 june, 26 june ... 1 january
And after that paste column with new date at the left.
Is any tool to invert columns in default MS Excel or in VBA ?
-
1Copy it, paste special and transpose, sort by your column, then copy/transpose back.enderland– enderland2014-06-28 12:09:16 +00:00Commented Jun 28, 2014 at 12:09
-
Thank you! Not ideal way, but worked. I think VBA can do this, did you saw some VBA script library ?Sergey Senkov– Sergey Senkov2014-06-28 12:28:52 +00:00Commented Jun 28, 2014 at 12:28
-
possible duplicate of sorting across sheets in excelIsaac G Sivaa– Isaac G Sivaa2014-07-02 17:51:44 +00:00Commented Jul 2, 2014 at 17:51
Add a comment
|
1 Answer
You could use this script from previous accepted answer about sorting columns across sheets: Sort excel columns across sheets
First create a new sheet as first in workbook. Then add columns headers with dates in desired order: 27 june... 1 june
Replace number of columns and number of sheets in script
Save a backup before running this macro, no undo.
After rearrangement delete first sheet
Sub ColumnRearrangement()
'Horaciux 2014-06-23
Dim nextLabel As String
Dim currentLabel As String
Dim TotalPages As Integer
Dim TotalColumns As Integer
TotalPages = 10
TotalColumns = 200
'Insert a blank column in each page
For p = 2 To TotalPages
Sheets(p).Select
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B1").Select
Next
For c = TotalColumns To 1 Step -1
Sheets(1).Select
'Debug.Print "-" & Cells(1, c).Text & "-" & Str(c)
nextLabel = Cells(1, c).Text
Sheets(2).Select
For oldCulumn = 2 To TotalColumns + 1
'Debug.Print Cells(1, oldCulumn).Text & "-" & Str(oldCulumn)
currentLabel = Cells(1, oldCulumn).Text
If currentLabel = nextLabel Then
'Debug.Print currentLabel & "-" & Str(oldCulumn)
Exit For
End If
Next
For p = 2 To TotalPages
Sheets(p).Select
Columns(oldCulumn).Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Next
Next
For p = 2 To TotalPages
Sheets(p).Select
Range("A1").Select
Next
End Sub
1 Comment
Horaciux
@SergeySenkov Does it work for you? Could you formally accept this answer?