Skip to content

Instantly share code, notes, and snippets.

@compustar
Created February 16, 2020 19:34
Show Gist options
  • Save compustar/209b311572a159aede96e5c974d5ec79 to your computer and use it in GitHub Desktop.
Save compustar/209b311572a159aede96e5c974d5ec79 to your computer and use it in GitHub Desktop.
Unpivoting Statistics on Passenger Traffic at https://www.immd.gov.hk/eng/message_from_us/stat.html
Sub Unpivot()
'
' Macro1 Macro
'
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("C5").Select
Selection.Copy
Columns("D:D").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("E10").Select
Selection.Copy
Range("D12:D26").Select
ActiveSheet.Paste
Range("C12:C26").Select
Application.CutCopyMode = False
Selection.Copy
Range("C27").Select
ActiveSheet.Paste
Range("I10").Select
Application.CutCopyMode = False
Selection.Copy
Range("D27").Select
ActiveWindow.SmallScroll Down:=12
Range("D27:D41").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-9
Range("I12:L26").Select
Application.CutCopyMode = False
Selection.Cut
Range("E27").Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-12
Columns("I:O").Select
Selection.Delete Shift:=xlToLeft
Range("C5").Select
Selection.Copy
Range("A12").Select
ActiveWindow.SmallScroll Down:=12
Range("A12:A41").Select
ActiveSheet.Paste
Rows("1:10").Select
Range("A10").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Range("C4").Select
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment