Hi, sirhar13reddy!
As a new user you might want to (I'd say should and must) read this:
http://chandoo.org/forum/forums/new-users-please-start-here.14/
And regarding your issue, give a look following solution. It uses a helper column N and a macro.
Formulas:
N2: =SI(ESBLANCO(G2);SI(ESBLANCO(D2);SI(ESBLANCO(H2);"";H2);SI(ESBLANCO(H2);D2;SI(D2<H2;D2;H2)));G2) -----> in english: =IF(ISBLANK(G2),IF(ISBLANK(D2),IF(ISBLANK(H2),"",H2),IF(ISBLANK(H2),D2,IF(D2<H2,D2,H2))),G2)
Macro:
Code:
Option Explicit
Sub ThereAreStrangeSortingMethodsButThisWins()
' constants
Const ksRange = "A:N"
Const ksInputWS = "Sheet1"
Const ksOutputWS = "Sheet2"
' declarations
Dim rngI As Range, rngO As Range
' start
Set rngI = Worksheets(ksInputWS).Range(ksRange).CurrentRegion
Set rngO = Worksheets(ksOutputWS).Range(ksRange)
' process
With rngO
.ClearContents
rngI.Copy .Cells(1, 1)
.Parent.Activate
.CurrentRegion.Sort [N2], , [A2], , , [B2], , xlYes
End With
' end
Set rngO = Nothing
Set rngI = Nothing
Beep
End Sub
Just advise if any issue.
Regards!
EDITED (SirJB7)
PS: There's no uploadable file, preformatted text wrongly copied. Fixed above.