Blank rows appearing at top after sorting

G

gmangad

I have an excel file with names in Column 'A' which starts with "MR " O
"MRS " as prefix. and I have the formula in B as follows.
IF(A1="","",IF(LEFT(A1,3)="MR ",MID(A1,4,LEN(A1)-3),IF(LEFT(A1,4)="MR
",MID(A1,5,LEN(A1)-4),A1)))

It works perfect
and I am running the following macro to sort column B alphabeticaly
but after sorting, the empty rows are apprearing at beginning. Ca
anyone help me???????
Sub Macro4()
Range("A1:B" & Range("B500").End(xlUp).Row).Select
Selection.Sort Key1:=Range("b1"), Order1:=xlAscending, Header:=xlNo
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub

Thanks in advance
G
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top