Hi,
I have a range of data A4:Z1000, header in row1, (row2 - row3 with titles that I do not want to touch at all), which I can sort using buttons for most of the columns EXCEPT column A. When I click button to sort column A with my code, it puts the blank cells returned in col A on the TOP first then the Ascending data below them. I do not want the blanks to be above, but below instead. I suspect the reason is because all other cols that have not been entered any data do not have this problem because they do not have a function. In col A, i have entered a function below, so I think even though the blanks appear blank, EXCEL is treating the "blanks" as zeros or a ghost data because of this function. But I need this function. This function in col A:
=IFERROR(IF(C5<>"",VLOOKUP(C5,'Dir - SEHK'!$A$2:$B$2000,2,FALSE),""),"check or upd Directory sheet")
where, 'Dir - SEHK' is another sheet the VLOOKUP derives the values to fill into col A.
How can my VBA code be tuned so as to automatically skip or put the sorted data where the "blanks" caused by col A ?
My code:
Sub sort_Name()
'
' sort_Name Macro
'
'
Range("A1:Z1000").Select
ActiveWorkbook.Worksheets("Register - SEHK").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Register - SEHK").Sort.SortFields.Add Key:=Range( _
"A4:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Register - SEHK").Sort
.SetRange Range("A4:Z1000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A3").Select
End Sub
Help, help ..
Jason
Bookmarks