Skip to content

Instantly share code, notes, and snippets.

@harsha547
Last active June 11, 2017 09:30
Show Gist options
  • Save harsha547/d1dd4b5ce935d2b50d8974aa31d259e8 to your computer and use it in GitHub Desktop.
Save harsha547/d1dd4b5ce935d2b50d8974aa31d259e8 to your computer and use it in GitHub Desktop.
Sub Sortcolumns()
Dim lcolumn As Long
Dim lookuprng As Range
lcolumn = Sheet1.Range("A4").CurrentRegion.Columns.Count
Set lookuprng = Sheet2.Range("B2:B10")
Sheet1.Range("A3") = "=Match(A4 , look ,0)"
Sheet1.Range(Cells(3, 1), Cells(3, lcolumn)).FillRight
Sheet1.Range("A3:D7").Sort Key1:=Range("A3:D3"), Order1:=xlAscending, Orientation:=xlLeftToRight
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment